summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/CheckboxEditorDialog.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 22:33:32 -0800
committerFuwn <[email protected]>2026-02-12 22:33:32 -0800
commitc7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch)
treedf9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/CheckboxEditorDialog.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/scape/CheckboxEditorDialog.java')
-rw-r--r--NET/worlds/scape/CheckboxEditorDialog.java64
1 files changed, 64 insertions, 0 deletions
diff --git a/NET/worlds/scape/CheckboxEditorDialog.java b/NET/worlds/scape/CheckboxEditorDialog.java
new file mode 100644
index 0000000..e8eb818
--- /dev/null
+++ b/NET/worlds/scape/CheckboxEditorDialog.java
@@ -0,0 +1,64 @@
+package NET.worlds.scape;
+
+import NET.worlds.console.Console;
+import NET.worlds.console.OkCancelDialog;
+import java.awt.Checkbox;
+import java.awt.CheckboxGroup;
+import java.awt.Dimension;
+import java.awt.GridBagConstraints;
+
+public abstract class CheckboxEditorDialog extends OkCancelDialog {
+ private CheckboxGroup group = new CheckboxGroup();
+ private Checkbox[] choices;
+ private String[] labels;
+ protected EditTile parent;
+
+ protected CheckboxEditorDialog(EditTile parent, String title, String[] labels) {
+ super(Console.getFrame(), parent, title);
+ this.labels = labels;
+ this.parent = parent;
+ }
+
+ @Override
+ protected void build() {
+ this.choices = new Checkbox[this.labels.length];
+ GridBagConstraints c = new GridBagConstraints();
+ c.weightx = 1.0;
+ c.weighty = 1.0;
+ c.gridwidth = 0;
+
+ for (int i = 0; i < this.labels.length; i++) {
+ this.add(this.gbag, this.choices[i] = new Checkbox(this.labels[i], this.group, false), c);
+ }
+
+ super.build();
+ }
+
+ protected abstract int getValue();
+
+ protected abstract void setValue(int var1);
+
+ @Override
+ protected boolean setValue() {
+ Checkbox selected = this.group.getCurrent();
+
+ for (int i = 0; i < this.choices.length; i++) {
+ if (this.choices[i] == selected) {
+ this.setValue(i);
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ @Override
+ public void show() {
+ Dimension mySize = this.size();
+ this.initialSize(mySize.width < 160 ? 160 : mySize.width, mySize.height < 120 ? 120 : mySize.height);
+ super.show();
+ int choice = this.getValue();
+ this.choices[choice].requestFocus();
+ this.choices[choice].setState(true);
+ }
+}