public class TestGUISwing3
1: //TestGUISwing3.java
2: //Add two buttons to a panel and add a panel to the frame.
4: import java.awt.*;
5: import javax.swing.*;
7: public class TestGUISwing3
8: {
9: public static void main(String[] args)
10: {
11: JFrame frame = new JFrame("My JFrame");
12: frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
14: JButton b1 = new JButton("First");
15: JButton b2 = new JButton("Second");
16: JPanel panel = new JPanel();
17: panel.add(b1);
18: panel.add(b2);
19: frame.getContentPane().add(panel);
21: frame.pack();
22: frame.show();
23: }
24: }