FileDocCategorySizeDatePackage
TextEntryBox.javaAPI DocExample885Sat Apr 23 22:35:40 BST 2005None

TextEntryBox

public class TextEntryBox extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

    JFrame frame = new JFrame("Text Entry Box");

    final JTextArea area = new JTextArea();
    area.setFont(new Font("Serif", Font.BOLD, 18));
    area.setText("Howdy!\n");
    final JTextField field = new JTextField();

    Container content = frame.getContentPane();
    content.add(new JScrollPane(area), BorderLayout.CENTER);
    content.add(field, BorderLayout.SOUTH);
    field.requestFocus();

    field.addActionListener(new ActionListener(  ) {
      public void actionPerformed(ActionEvent ae) {
        area.append(field.getText(  ) + '\n");
        field.setText("");
      }
    });

	frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    frame.setSize(200, 300);
    frame.setVisible(true);