KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jimm > datavision > gui > parameter > SingleStringInq


1 package jimm.datavision.gui.parameter;
2 import jimm.datavision.Parameter;
3 import javax.swing.*;
4
5 /**
6  * A single string inquisitor knows how to display and control the widgets
7  * needed to ask a user for a string parameter value.
8  *
9  * @author Jim Menard, <a HREF="mailto:jimm@io.com">jimm@io.com</a>
10  */

11 class SingleStringInq extends Inquisitor {
12
13 protected JTextField textField;
14
15 SingleStringInq(Parameter param) {
16     super(param);
17     // Build GUI
18
panel.add(textField = new JTextField(TEXT_FIELD_COLS));
19     // Fill in default value
20
textField.setText(parameter.getDefaultValue(0).toString());
21
22     // Copy default value into "real" value
23
parameter.setValue(0, parameter.getDefaultValue(0));
24 }
25
26 void copyGUIIntoParam() {
27     // setValue translates the string to the appropriate numeric type
28
// (integer or float).
29
parameter.setValue(0, textField.getText());
30 }
31
32 void copyParamIntoGUI() {
33     textField.setText(parameter.getValue(0).toString());
34 }
35
36 }
37
Popular Tags