From 93a120cafe4b9b0b2ee895b400e542225f415fd2 Mon Sep 17 00:00:00 2001 From: cubewhy Date: Sat, 13 Jan 2024 18:48:42 +0800 Subject: [PATCH] use GridLayout to fix crash --- .../celestial/gui/dialogs/ArgsConfigDialog.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/cubewhy/celestial/gui/dialogs/ArgsConfigDialog.java b/src/main/java/org/cubewhy/celestial/gui/dialogs/ArgsConfigDialog.java index 5a0ea90b..2030e365 100644 --- a/src/main/java/org/cubewhy/celestial/gui/dialogs/ArgsConfigDialog.java +++ b/src/main/java/org/cubewhy/celestial/gui/dialogs/ArgsConfigDialog.java @@ -10,10 +10,13 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import lombok.extern.slf4j.Slf4j; +import org.cubewhy.celestial.gui.layouts.VerticalFlowLayout; import org.jetbrains.annotations.NotNull; import javax.swing.*; +import java.awt.*; + import static org.cubewhy.celestial.Celestial.config; import static org.cubewhy.celestial.Celestial.f; @@ -28,7 +31,7 @@ public ArgsConfigDialog(String key, @NotNull JsonObject json) { this.key = key; this.json = json; this.array = json.getAsJsonArray(key); - this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); + this.setLayout(new GridLayout(2, 1)); this.initGui(); this.setSize(600, 600); this.setModalityType(ModalityType.APPLICATION_MODAL); @@ -48,8 +51,8 @@ private void initGui() { for (JsonElement element : array) { model.addElement(element.getAsString()); } - this.add(args); } + this.add(args); JPanel panelButtons = new JPanel(); panelButtons.setLayout(new BoxLayout(panelButtons, BoxLayout.X_AXIS)); // btnAdd @@ -65,7 +68,8 @@ private void initGui() { btnRemove.addActionListener((e) -> { if (JOptionPane.showConfirmDialog(this, String.format(f.getString("gui.settings.args.remove.confirm"), args.getSelectedValue()), "Confirm", JOptionPane.YES_NO_OPTION) == JOptionPane.NO_OPTION) { return; - }; + } + ; int index = args.getSelectedIndex(); this.removeArg(index, model); });