Demonstrating the WindowListener with a WindowAdapter : Various Event Listener « Swing JFC « Java






Demonstrating the WindowListener with a WindowAdapter

Demonstrating the WindowListener with a WindowAdapter
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;

import javax.swing.JFrame;

public class WindowAdapterTest {
  public static void main(String args[]) {
    JFrame frame = new JFrame("Window Listener");
    WindowListener listener = new WindowAdapter() {
      public void windowClosing(WindowEvent w) {
        System.exit(0);
      }
    };
    frame.addWindowListener(listener);
    frame.setSize(300, 300);
    frame.show();
  }
}
           
       








Related examples in the same category

1.Demonstrating the ActionListenerDemonstrating the ActionListener
2.Demonstrating the AdjustmentListenerDemonstrating the AdjustmentListener
3.Demonstrating the AncestorListener
4.Demonstrating the ComponentListenerDemonstrating the ComponentListener
5.Demonstrating the ContainerListenerDemonstrating the ContainerListener
6.Demonstrating the FocusListenerDemonstrating the FocusListener
7.Demonstrating the HyperlinkListenerDemonstrating the HyperlinkListener
8.Demonstrating the InternalFrameListenerDemonstrating the InternalFrameListener
9.Demonstrating the ItemListenerDemonstrating the ItemListener
10.Demonstrating the KeyListenerDemonstrating the KeyListener
11.Demonstrating the MenuListenerDemonstrating the MenuListener
12.Demonstrating the MouseListener and MouseMotionListenerDemonstrating the MouseListener and MouseMotionListener
13.Demonstrating the MouseWheelListenerDemonstrating the MouseWheelListener
14.Demonstrating the PopupMenuListenerDemonstrating the PopupMenuListener
15.Demonstrating the WindowListener
16.Responding to KeystrokesResponding to Keystrokes