package sale.stdforms; import sale.*; import util.swing.*; import javax.swing.*; /** * A simple FormSheet that displays a label and an {@link JTextInput input line}. * * <p>The FormSheet uses a {@link sale.FormSheetContentCreator} to create its contents.</p> * * @author Steffen Zschaler * @version 2.0 12/07/1999 * @since v2.0 */ public class TextInputForm extends FormSheet { /** * The String array that will hold the text that was entered into the text field. * * @serial */ private String[] m_asResult = new String[] {""}; /** * Create a new TextInputForm. * * @param sCaption the caption of the FormSheet. * @param sLabel the label to be put at the top of the FormSheet. * @param sInitialText the text that is to appear in the input line when the user has not entered anything * yet. * @param fWaitResponse, the initial value for the "{@link FormSheet#waitResponse}" property. */ public TextInputForm (String sCaption, final String sLabel, String sInitialText, boolean fWaitResponse) { super (sCaption, (JComponent) null, fWaitResponse); m_asResult[0] = sInitialText; addContentCreator (new FormSheetContentCreator() { protected void createFormSheetContent (FormSheet fs) { JPanel jpForm = new JPanel(); Box b = Box.createVerticalBox(); b.add (Box.createVerticalGlue()); b.add (new JLabel (sLabel)); b.add (new JTextInput (m_asResult, m_asResult[0])); b.add (Box.createGlue()); jpForm.add (b); fs.setComponent (jpForm); } }); } /** * Create a new TextInputForm. The value for the "{@link FormSheet#waitResponse}" property will * initially be set to true. * * @param sCaption the caption of the FormSheet. * @param sLabel the label to be put at the top of the FormSheet. * @param sInitialText the text that is to appear in the input line when the user has not entered anything * yet. */ public TextInputForm (String sCaption, String sLabel, String sInitialText) { this (sCaption, sLabel, sInitialText, true); } /** * Get the current contents of the input field. * * @override Never */ public String getText() { return m_asResult[0]; } }