public class FirstSwingDemo
1:
2: import javax.swing.JFrame;
3: import javax.swing.JLabel;
4:
5: /**
6: A simple demonstration of a window constructed using Swing.
7: */
8: public class FirstSwingDemo
9: {
10: public static final int WIDTH = 300;
11: public static final int HEIGHT = 200;
12:
13: public static void main(String[] args)
14: {
15: JFrame myWindow = new JFrame( );
16: myWindow.setSize(WIDTH, HEIGHT);
17: JLabel myLabel =
18: new JLabel("Please don’t click that button!");
19: myWindow.getContentPane( ).add(myLabel);
20:
21: WindowDestroyer myListener = new WindowDestroyer( );
22: myWindow.addWindowListener(myListener);
23:
24: myWindow.setVisible(true);
25: }
26: }