Source of SimpleWindow.java


  1: import javax.swing.*;
  2: import java.awt.*;
  3: 
  4: public class SimpleWindow extends JFrame
  5: {
  6:         public static final int WIDTH = 300;
  7:         public static final int HEIGHT = 200;
  8: 
  9:         public SimpleWindow()
 10:         {
 11:                 setSize(WIDTH,HEIGHT);
 12:                 Container contentPane = getContentPane();
 13: 
 14:                 JLabel label = new JLabel("You can display text using a label.");
 15:                 contentPane.add(label);
 16: 
 17:                 contentPane.setBackground(Color.GREEN);
 18:                 addWindowListener(new WindowDestroyer());
 19:         }
 20: 
 21:         public static void main(String[] args)
 22:         {
 23:                 SimpleWindow window = new SimpleWindow();
 24:                 window.setVisible(true);
 25:         }
 26: }