Skip to content

Commit

Permalink
use GridLayout to fix crash
Browse files Browse the repository at this point in the history
  • Loading branch information
cubewhy committed Jan 13, 2024
1 parent d761e2f commit 93a120c
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
Expand All @@ -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
Expand All @@ -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);
});
Expand Down

0 comments on commit 93a120c

Please sign in to comment.