FileDocCategorySizeDatePackage
TextDemo.javaAPI DocExample1631Tue Dec 12 18:59:16 GMT 2000None

TextDemo

public class TextDemo extends JApplet implements ActionListener

Fields Summary
JTextField
textField
JTextArea
textArea
String
newline
Constructors Summary
public TextDemo()


    //Hack to avoid annoying error message (1.1).
      
        getRootPane().putClientProperty("defeatSystemEventQueueCheck",
                                        Boolean.TRUE);
    
Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent evt)

        String text = textField.getText();
        textArea.append(text + newline);
        textField.selectAll();
    
public voidinit()

        textField = new JTextField(20);
        textField.addActionListener(this);

        textArea = new JTextArea(5, 20);
        textArea.setEditable(false);
        JScrollPane scrollPane = new JScrollPane(textArea,
                                       JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
                                       JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

        //Add Components to the Applet. 
        GridBagLayout gridBag = new GridBagLayout();
        Container contentPane = getContentPane();
        contentPane.setLayout(gridBag);
        GridBagConstraints c = new GridBagConstraints();
        c.gridwidth = GridBagConstraints.REMAINDER;

        c.fill = GridBagConstraints.HORIZONTAL;
        gridBag.setConstraints(textField, c);
        contentPane.add(textField);

        c.fill = GridBagConstraints.BOTH;
        c.weightx = 1.0;
        c.weighty = 1.0;
        gridBag.setConstraints(scrollPane, c);
        contentPane.add(scrollPane);