01: package jimm.datavision.gui.parameter;
02:
03: import jimm.datavision.Parameter;
04: import javax.swing.*;
05:
06: /**
07: * A single string inquisitor knows how to display and control the widgets
08: * needed to ask a user for a string parameter value.
09: *
10: * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
11: */
12: class SingleStringInq extends Inquisitor {
13:
14: protected JTextField textField;
15:
16: SingleStringInq(Parameter param) {
17: super (param);
18: // Build GUI
19: panel.add(textField = new JTextField(TEXT_FIELD_COLS));
20: // Fill in default value
21: textField.setText(parameter.getDefaultValue(0).toString());
22:
23: // Copy default value into "real" value
24: parameter.setValue(0, parameter.getDefaultValue(0));
25: }
26:
27: void copyGUIIntoParam() {
28: // setValue translates the string to the appropriate numeric type
29: // (integer or float).
30: parameter.setValue(0, textField.getText());
31: }
32:
33: void copyParamIntoGUI() {
34: textField.setText(parameter.getValue(0).toString());
35: }
36:
37: }
|