public class TestGUISwing8
1: //TestGUISwing8.java
2: //This time add a button first, then the panel with two buttons.
4: import java.awt.*;
5: import java.awt.event.*;
6: import javax.swing.*;
8: public class TestGUISwing8
9: {
10: public static void main(String[] args)
11: {
12: JFrame frame = new JFrame("My JFrame");
13: frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
15: JPanel panel = new JPanel();
16: JButton b1 = new JButton("First");
17: JButton b2 = new JButton("Second");
18: panel.add(b1);
19: panel.add(b2);
20:
21: JButton b3 = new JButton("Third");
22: frame.getContentPane().add(b3);
24: frame.getContentPane().add(panel);
26: frame.pack();
27: frame.show();
28: }
29: }