01: package jimm.datavision.gui.parameter;
02:
03: import jimm.datavision.Parameter;
04: import jimm.util.I18N;
05: import javax.swing.*;
06:
07: /**
08: * A boolean inquisitor knows how to display and control the widgets needed
09: * to ask a user for boolean parameter values.
10: *
11: * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
12: */
13: class BoolInq extends Inquisitor {
14:
15: protected JRadioButton boolYesRButton;
16: protected JRadioButton boolNoRButton;
17:
18: BoolInq(Parameter param) {
19: super (param);
20:
21: // Build GUI
22: Box box = Box.createVerticalBox();
23: ButtonGroup bg = new ButtonGroup();
24:
25: boolYesRButton = new JRadioButton(I18N.get("GUI.yes"));
26: box.add(boolYesRButton);
27: bg.add(boolYesRButton);
28:
29: boolNoRButton = new JRadioButton(I18N.get("GUI.no"));
30: box.add(boolNoRButton);
31: bg.add(boolNoRButton);
32:
33: panel.add(box);
34:
35: // Copy default value into "real" value
36: parameter.setValue(0, parameter.getDefaultValue(0));
37: }
38:
39: void copyGUIIntoParam() {
40: parameter.setValue(0, Boolean.valueOf(boolYesRButton
41: .isSelected()));
42: }
43:
44: void copyParamIntoGUI() {
45: if (((Boolean) parameter.getValue(0)).booleanValue())
46: boolYesRButton.setSelected(true);
47: else
48: boolNoRButton.setSelected(true);
49: }
50:
51: }
|