com.croftsoft.core.gui
Class ShutdownWindowListener

java.lang.Object
  extended by java.awt.event.WindowAdapter
      extended by com.croftsoft.core.gui.ShutdownWindowListener
All Implemented Interfaces:
WindowFocusListener, WindowListener, WindowStateListener, EventListener

public class ShutdownWindowListener
extends WindowAdapter

Performs a graceful shutdown of a program when the window is closed.

  1. Sets window visibility to false.
  2. Calls the destroy() method, in array order, of each of the Destroyable instances passed via the constructor argument. Any exceptions are caught, printed, and ignored.
  3. Calls the window dispose() method.
  4. Calls System.exit(0).

Example:

 frame.addWindowListener (
   new ShutdownWindowListener ( destroyables ) );
 

Java 1.1 compatible.

Since:
2001-03-06
Version:
2001-07-20
Author:
David Wallace Croft

Constructor Summary
ShutdownWindowListener()
          Convenience constructor.
ShutdownWindowListener(Destroyable destroyable)
          Convenience constructor.
ShutdownWindowListener(Destroyable[] destroyables)
          Main constructor.
 
Method Summary
 void windowClosing(WindowEvent windowEvent)
           
 
Methods inherited from class java.awt.event.WindowAdapter
windowActivated, windowClosed, windowDeactivated, windowDeiconified, windowGainedFocus, windowIconified, windowLostFocus, windowOpened, windowStateChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShutdownWindowListener

public ShutdownWindowListener(Destroyable[] destroyables)
Main constructor.

Parameters:
destroyables - May be null.

ShutdownWindowListener

public ShutdownWindowListener(Destroyable destroyable)
Convenience constructor.
 this ( new Destroyable [ ] { destroyable } );
 


ShutdownWindowListener

public ShutdownWindowListener()
Convenience constructor.
 this ( ( Destroyable [ ] ) null );
 

Method Detail

windowClosing

public void windowClosing(WindowEvent windowEvent)
Specified by:
windowClosing in interface WindowListener
Overrides:
windowClosing in class WindowAdapter

CroftSoft Javadoc

CroftSoft Core Javadoc (2008-09-28 20:58:02)