SingleStringInq.java :  » Report » datavision-1.1.0 » jimm » datavision » gui » parameter » Java Open Source

Java Open Source » Report » datavision 1.1.0 
datavision 1.1.0 » jimm » datavision » gui » parameter » SingleStringInq.java
package jimm.datavision.gui.parameter;
import jimm.datavision.Parameter;
import javax.swing.*;

/**
 * A single string inquisitor knows how to display and control the widgets
 * needed to ask a user for a string parameter value.
 *
 * @author Jim Menard, <a href="mailto:jimm@io.com">jimm@io.com</a>
 */
class SingleStringInq extends Inquisitor {

protected JTextField textField;

SingleStringInq(Parameter param) {
    super(param);
    // Build GUI
    panel.add(textField = new JTextField(TEXT_FIELD_COLS));
    // Fill in default value
    textField.setText(parameter.getDefaultValue(0).toString());

    // Copy default value into "real" value
    parameter.setValue(0, parameter.getDefaultValue(0));
}

void copyGUIIntoParam() {
    // setValue translates the string to the appropriate numeric type
    // (integer or float).
    parameter.setValue(0, textField.getText());
}

void copyParamIntoGUI() {
    textField.setText(parameter.getValue(0).toString());
}

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.