com.sas.util
Class CloseWindowAdaptor

com.sas.util.CloseWindowAdaptor
All Implemented Interfaces:
java.awt.event.WindowListener, java.util.EventListener

public class CloseWindowAdaptor
implements java.awt.event.WindowListener

CloseWindowAdaptor is an adaptor object which listens for a WindowEvent and disposes a window (i.e. closes it) when a window receives a close event.

  CloseWindowAdaptor closeAdaptor = new CloseWindowAdaptor(window);
 
is all that is needed to make a window close when it received a close request (normally from the window manager, such as clicking the X icon in Microsoft Windows).

Normally, the adaptor only listens for window events from this window, but you can also add the adaptor as a window listener on other windows. For example, if you have a parent window and a non-modal dialog, you can use a CloseWindowAdaptor to close the dialog when the primary window closes:

  MyAppFrame parent = new MyAppFrame();
  // cause the parent window to close when it receives a close request
  CloseWindowAdaptor closeParent = new CloseWindowAdaptor(parent);
  // create a non-modal dialog
  Dialog d = new Dialog(parent);
  // allow the dialog to close itself
  CloseWindowAdaptor closeDialog = new CloseWindowAdaptor(dialog);
  // Have the parent close the dialog when the parent window closes:
  parent.addWindowListener(closeDialog);
 

The only method in the WindowListener interface that is implemented is windowClosing(windowEvent)


Field Summary
protected  java.awt.Window window
          The window this adaptor is listening to.
 
Constructor Summary
CloseWindowAdaptor(java.awt.Window window)
          Construct a CloseWindowAdaptor which will dispose the window when a windowClosing event is received.
 
Method Summary
 void windowActivated(java.awt.event.WindowEvent wEvent)
          No op.
 void windowClosed(java.awt.event.WindowEvent wEvent)
          No op.
 void windowClosing(java.awt.event.WindowEvent wEvent)
          When a UI action to close the window occurs, this handler executes and disposes the window.
 void windowDeactivated(java.awt.event.WindowEvent wEvent)
          No op.
 void windowDeiconified(java.awt.event.WindowEvent wEvent)
          No op.
 void windowIconified(java.awt.event.WindowEvent wEvent)
          No op.
 void windowOpened(java.awt.event.WindowEvent wEvent)
          No op.
 

Field Detail

window

protected java.awt.Window window
The window this adaptor is listening to.

Constructor Detail

CloseWindowAdaptor

public CloseWindowAdaptor(java.awt.Window window)
Construct a CloseWindowAdaptor which will dispose the window when a windowClosing event is received.

Parameters:
window - the window to close. The new adaptor is added as a WindowEventListener.
Method Detail

windowOpened

public void windowOpened(java.awt.event.WindowEvent wEvent)
No op.

Specified by:
windowOpened in interface java.awt.event.WindowListener

windowClosing

public void windowClosing(java.awt.event.WindowEvent wEvent)
When a UI action to close the window occurs, this handler executes and disposes the window. This adaptor closes the window that was passed to the constructor, (which may not be the window that sends the event).

Specified by:
windowClosing in interface java.awt.event.WindowListener
Parameters:
wEvent - a window event. The event is ignored.

windowClosed

public void windowClosed(java.awt.event.WindowEvent wEvent)
No op.

Specified by:
windowClosed in interface java.awt.event.WindowListener

windowIconified

public void windowIconified(java.awt.event.WindowEvent wEvent)
No op.

Specified by:
windowIconified in interface java.awt.event.WindowListener

windowDeiconified

public void windowDeiconified(java.awt.event.WindowEvent wEvent)
No op.

Specified by:
windowDeiconified in interface java.awt.event.WindowListener

windowActivated

public void windowActivated(java.awt.event.WindowEvent wEvent)
No op.

Specified by:
windowActivated in interface java.awt.event.WindowListener

windowDeactivated

public void windowDeactivated(java.awt.event.WindowEvent wEvent)
No op.

Specified by:
windowDeactivated in interface java.awt.event.WindowListener



Copyright © 2009 SAS Institute Inc. All Rights Reserved.