01: import java.awt.*;
02: import javax.swing.*;
03:
04: public class FrameTest
05: {
06: public static void main(String[] args)
07: {
08: JFrame frame = new JFrame();
09:
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: Container contentPane = frame.getContentPane();
18: contentPane.setLayout(new FlowLayout());
19:
20: contentPane.add(helloButton);
21: contentPane.add(goodbyeButton);
22: contentPane.add(textField);
23:
24: frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
25: frame.pack();
26: frame.show();
27: }
28: }