The WizardTextBoxPanel component.

Component Java
Build Wizards Quickly Using a Swing-Based Wizard Framework
Chang Sau Sheong
Listing 5. The WizardTextBoxPanel component.

. . .

public class WizardTextBoxPanel extends JPanel implements
        WizardComponent {

  JLabel label = new JLabel();
  JTextField textBox = new JTextField();
  Hashtable container = new Hashtable();

  public WizardTextBoxPanel(String labelText, int textLength) {
    label = new JLabel(labelText);
    textBox = new JTextField(textLength);
    setLayout(new BorderLayout());
    add(label, BorderLayout.WEST);
    add(textBox, BorderLayout.EAST);

  public WizardTextBoxPanel(Hashtable textBoxList) {
    if (!textBoxList.isEmpty()) {
      JPanel leftPane = new JPanel();
      JPanel rightPane = new JPanel();


       Enumeration textBoxes = textBoxList.keys();
       while (textBoxes.hasMoreElements()) {
	         String labelName = (String)textBoxes.nextElement();
	         label = new JLabel(labelName);
	         Integer textBoxLength =
           textBox = new JTextField(textBoxLength.intValue());
	          container.put(labelName, textBox);
	       add(leftPane, BorderLayout.WEST);
	       add(rightPane, BorderLayout.EAST);

  public String getComponentData() throws WizardException{
	       return textBox.getText();

  public String getComponentData(String textBoxName)
                            throws WizardException {
	       JTextField textField =
	       return textField.getText();

  public Hashtable getAllComponentData() throws WizardException {
return null;

. . .

About the Author

Chang Sau Sheong is vice president of product engineering at elipva Ltd. (formerly known as He can be contacted at



Sign up for our newsletter.

Terms and Privacy Policy consent

I agree to this site's Privacy Policy.

Upcoming Events