home *** CD-ROM | disk | FTP | other *** search
/ Java 1.2 How-To / JavaHowTo.iso / javafile / ch05 / Windows1.java < prev   
Encoding:
Java Source  |  1998-12-14  |  1.3 KB  |  64 lines

  1. import java.util.*;
  2. import java.awt.*;
  3. import java.awt.event.*;
  4. import javax.swing.*;
  5. import javax.swing.text.*;
  6.  
  7. public class Windows1 extends Object implements WindowListener
  8. {
  9.     public void windowOpened(WindowEvent e)
  10.     {
  11.         System.out.println("Window opened.");
  12.     }
  13.  
  14.     public void windowClosing(WindowEvent e)
  15.     {
  16.         System.out.println("Window closing.");
  17.  System.exit(0);
  18.  
  19.     }
  20.  
  21.     public void windowClosed(WindowEvent e)
  22.     {
  23.         System.out.println("Window closed.");
  24.     }
  25.  
  26.     public void windowIconified(WindowEvent e)
  27.     {
  28.         System.out.println("Window iconified.");
  29.     }
  30.  
  31.     public void windowDeiconified(WindowEvent e)
  32.     {
  33.         System.out.println("Window deiconified.");
  34.     }
  35.  
  36.     public void windowActivated(WindowEvent e)
  37.     {
  38.  
  39.         System.out.println("Window activated.");
  40.     }
  41.  
  42.     public void windowDeactivated(WindowEvent e)
  43.     {
  44.         System.out.println("Window deactivated");
  45.     }
  46.  
  47.     public static void main(String s[])
  48.     {
  49.         JFrame frame = new JFrame("Windows1");
  50.  
  51.         frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
  52.         frame.addWindowListener(new Windows1());
  53.  
  54.  
  55.  
  56. frame.getContentPane().add( new Label("Hello World"), "Center");
  57.  
  58.         frame.pack();
  59.         frame.setVisible(true);
  60.     }
  61.  
  62.  
  63. }
  64.