java.awt.event

Interface WindowListener

All Superinterfaces:
EventListener
Known Implementing Classes:
AWTEventMulticaster, BasicToolBarUI.FrameListener, JMenu.WinListener, WindowAdapter

public interface WindowListener
extends EventListener

The listener interface for receiving window events. The class that is interested in processing a window event either implements this interface (and all the methods it contains) or extends the abstract WindowAdapter class (overriding only the methods of interest). The listener object created from that class is then registered with a Window using the window's addWindowListener method. When the window's status changes by virtue of being opened, closed, activated or deactivated, iconified or deiconified, the relevant method in the listener object is invoked, and the WindowEvent is passed to it.
Since:
1.1
See Also:
WindowAdapter, WindowEvent, Tutorial: How to Write Window Listeners

Method Summary

void
windowActivated(WindowEvent e)
Invoked when the Window is set to be the active Window.
void
windowClosed(WindowEvent e)
Invoked when a window has been closed as the result of calling dispose on the window.
void
windowClosing(WindowEvent e)
Invoked when the user attempts to close the window from the window's system menu.
void
windowDeactivated(WindowEvent e)
Invoked when a Window is no longer the active Window.
void
windowDeiconified(WindowEvent e)
Invoked when a window is changed from a minimized to a normal state.
void
windowIconified(WindowEvent e)
Invoked when a window is changed from a normal to a minimized state.
void
windowOpened(WindowEvent e)
Invoked the first time a window is made visible.

Method Details

windowActivated

public void windowActivated(WindowEvent e)
Invoked when the Window is set to be the active Window. Only a Frame or a Dialog can be the active Window. The native windowing system may denote the active Window or its children with special decorations, such as a highlighted title bar. The active Window is always either the focused Window, or the first Frame or Dialog that is an owner of the focused Window.
Usages and Demos :

View More Examples of windowActivated(WindowEvent e)
   1: import java.awt.event.WindowEvent;
   2: import java.awt.event.WindowListener;
   3: import javax.swing.event.InternalFrameEvent;
   4:         ...
   5: final class InternalWindowListener implements InternalFrameListener {
   6:     private final WindowListener listener;
   7: 
   8:         ...
   9:     public static InternalFrameListener wrap(final WindowListener listener) {
  10:         if (listener == null) {
  11:         ...
  12:     public void internalFrameActivated(InternalFrameEvent event) {
  13:         listener.windowActivated(null);

View Full Code Here

windowClosed

public void windowClosed(WindowEvent e)
Invoked when a window has been closed as the result of calling dispose on the window.
Usages and Demos :

View More Examples of windowClosed(WindowEvent e)
   1: import java.awt.event.WindowEvent;
   2: import java.awt.event.WindowListener;
   3: import javax.swing.event.InternalFrameEvent;
   4:         ...
   5: final class InternalWindowListener implements InternalFrameListener {
   6:     private final WindowListener listener;
   7: 
   8:         ...
   9:     public static InternalFrameListener wrap(final WindowListener listener) {
  10:         if (listener == null) {
  11:         ...
  12:     public void internalFrameClosed(InternalFrameEvent event) {
  13:         listener.windowClosed(null);

View Full Code Here

windowClosing

public void windowClosing(WindowEvent e)
Invoked when the user attempts to close the window from the window's system menu.
Usages and Demos :

View More Examples of windowClosing(WindowEvent e)
   1: import java.awt.event.WindowEvent;
   2: import java.awt.event.WindowListener;
   3: import javax.swing.event.InternalFrameEvent;
   4:         ...
   5: final class InternalWindowListener implements InternalFrameListener {
   6:     private final WindowListener listener;
   7: 
   8:         ...
   9:     public static InternalFrameListener wrap(final WindowListener listener) {
  10:         if (listener == null) {
  11:         ...
  12:     public void internalFrameClosing(InternalFrameEvent event) {
  13:         listener.windowClosing(null);

View Full Code Here
   1: import java.awt.event.WindowEvent;
   2: import java.awt.event.WindowListener;
   3: 
   4:         ...
   5:             final JDialog dlg=new JDialog(frame,title,true);
   6:             final WindowListener wl=new WindowAdapter(){
   7:                 public void windowClosing(WindowEvent evt){
   8:         ...
   9:     }
  10:     private JComponent createEntryPanel(final AdminIterator iter,final WindowListener wl)
  11:         throws Exception{
  12:         ...
  13:             public void actionPerformed(ActionEvent evt){
  14:                 wl.windowClosing(null);

View Full Code Here

windowDeactivated

public void windowDeactivated(WindowEvent e)
Invoked when a Window is no longer the active Window. Only a Frame or a Dialog can be the active Window. The native windowing system may denote the active Window or its children with special decorations, such as a highlighted title bar. The active Window is always either the focused Window, or the first Frame or Dialog that is an owner of the focused Window.
Usages and Demos :

View More Examples of windowDeactivated(WindowEvent e)
   1: import java.awt.event.WindowEvent;
   2: import java.awt.event.WindowListener;
   3: import javax.swing.event.InternalFrameEvent;
   4:         ...
   5: final class InternalWindowListener implements InternalFrameListener {
   6:     private final WindowListener listener;
   7: 
   8:         ...
   9:     public static InternalFrameListener wrap(final WindowListener listener) {
  10:         if (listener == null) {
  11:         ...
  12:     public void internalFrameDeactivated(InternalFrameEvent event) {
  13:         listener.windowDeactivated(null);

View Full Code Here

windowDeiconified

public void windowDeiconified(WindowEvent e)
Invoked when a window is changed from a minimized to a normal state.
Usages and Demos :

View More Examples of windowDeiconified(WindowEvent e)
   1: import java.awt.event.WindowEvent;
   2: import java.awt.event.WindowListener;
   3: import javax.swing.event.InternalFrameEvent;
   4:         ...
   5: final class InternalWindowListener implements InternalFrameListener {
   6:     private final WindowListener listener;
   7: 
   8:         ...
   9:     public static InternalFrameListener wrap(final WindowListener listener) {
  10:         if (listener == null) {
  11:         ...
  12:     public void internalFrameDeiconified(InternalFrameEvent event) {
  13:         listener.windowDeiconified(null);

View Full Code Here

windowIconified

public void windowIconified(WindowEvent e)
Invoked when a window is changed from a normal to a minimized state. For many platforms, a minimized window is displayed as the icon specified in the window's iconImage property.
Usages and Demos :

View More Examples of windowIconified(WindowEvent e)
   1: import java.awt.event.WindowEvent;
   2: import java.awt.event.WindowListener;
   3: import javax.swing.event.InternalFrameEvent;
   4:         ...
   5: final class InternalWindowListener implements InternalFrameListener {
   6:     private final WindowListener listener;
   7: 
   8:         ...
   9:     public static InternalFrameListener wrap(final WindowListener listener) {
  10:         if (listener == null) {
  11:         ...
  12:     public void internalFrameIconified(InternalFrameEvent event) {
  13:         listener.windowIconified(null);

View Full Code Here

windowOpened

public void windowOpened(WindowEvent e)
Invoked the first time a window is made visible.
Usages and Demos :

View More Examples of windowOpened(WindowEvent e)
   1: import java.awt.event.WindowEvent;
   2: import java.awt.event.WindowListener;
   3: import javax.swing.event.InternalFrameEvent;
   4:         ...
   5: final class InternalWindowListener implements InternalFrameListener {
   6:     private final WindowListener listener;
   7: 
   8:         ...
   9:     public static InternalFrameListener wrap(final WindowListener listener) {
  10:         if (listener == null) {
  11:         ...
  12:     public void internalFrameOpened(InternalFrameEvent event) {
  13:         listener.windowOpened(null);

View Full Code Here