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