1 import java.awt.*;
2 import javax.swing.*;
3
4 public class FrameTester
5 {
6 public static void main(String[] args)
7 {
8 JFrame frame = new JFrame();
9
10 JButton helloButton = new JButton("Say Hello");
11 JButton goodbyeButton = new JButton("Say Goodbye");
12
13 final int FIELD_WIDTH = 20;
14 JTextField textField = new JTextField(FIELD_WIDTH);
15 textField.setText("Click a button!");
16
17 frame.setLayout(new FlowLayout());
18
19 frame.add(helloButton);
20 frame.add(goodbyeButton);
21 frame.add(textField);
22
23 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
24 frame.pack();
25 frame.setVisible(true);
26 }
27 }