blob: e8eb8188eddcac953abd43dfd97d9a9597d7beea (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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);
}
}
|