Source of SecondWindow.java


  1: 
  2: import javax.swing.JFrame;
  3: import javax.swing.JLabel;
  4: import java.awt.Color;
  5: import java.awt.Container;
  6: 
  7: public class SecondWindow extends JFrame
  8: {
  9:     public static final int WIDTH = 200;
 10:     public static final int HEIGHT = 200;
 11: 
 12:     public SecondWindow( )
 13:     {
 14:         super( );
 15: 
 16:         setSize(WIDTH, HEIGHT);
 17: 
 18:         Container contentPane = getContentPane( );
 19:         JLabel label = new JLabel("Now available in color!");
 20:         contentPane.add(label);
 21: 
 22:         setTitle("Second Window");
 23:         contentPane.setBackground(Color.BLUE);
 24: 
 25:         addWindowListener(new WindowDestroyer( ));
 26:     }
 27: 
 28:     public SecondWindow(Color customColor)
 29:     {
 30:         super( );
 31: 
 32:         setSize(WIDTH, HEIGHT);
 33: 
 34:         Container contentPane = getContentPane( );
 35:         JLabel label = new JLabel("Now available in color!");
 36:         contentPane.add(label);
 37: 
 38:         setTitle("Second Window");
 39:         contentPane.setBackground(customColor);
 40: 
 41:         addWindowListener(new WindowDestroyer( ));
 42:     }
 43: }
 44: 
 45: 
 46: 
 47: 
 48: