|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.event.WindowAdapter | +--lava.gui.FrameCloser
Automatically closes frame.
Details: FrameCloser
simplifies the task of creating closable Frame
s. (By default, Frame
s do not close automatically when the close command is selected.) To make a Frame
closable, simply create a new FrameCloser
with the Frame
as a parameter. There is no need to retain the constructed instance. An additional parameter can be supplied to indicate whether the whole program should exit when the frame is closed.
Example:
Frame frame = new Frame ("frame title here"); // true means to exit the program when the frame is closed: new FrameCloser (frame, true); // now configure and populate frame...Notice that the newly constructed
FrameCloser
is not retained in any variable, because there is no need to refer to theFrameCloser
again.
Note: Note that some Java graphics libraries offer a subclass of Frame that closes automatically, such as "ClosableFrame." While this type of solution is also effective, the FrameCloser approach is more versatile because it allows you to arbitrarily add a closable property to already existing Frame subclasses.
Constructor Summary | |
FrameCloser(java.awt.Frame frame)
Initializes with default values. |
|
FrameCloser(java.awt.Frame frame,
boolean exit)
Sets exit feature. |
Method Summary | |
void |
windowClosing(java.awt.event.WindowEvent e)
Reserved method. |
Methods inherited from class java.awt.event.WindowAdapter |
windowActivated, windowClosed, windowDeactivated, windowDeiconified, windowIconified, windowOpened |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public FrameCloser(java.awt.Frame frame, boolean exit)
Details: This constructor initializes a new FrameCloser
to respond to the given Frame
's close commands. The exit parameter indicates whether the program should exit when the window is closed.
frame
- the frame to closeexit
- whether the program should exit when the frame is closed (default value: false)public FrameCloser(java.awt.Frame frame)
Details: This constructor initializes a new FrameCloser
to respond to the given Frame
's close commands. The window will close, but the application will not exit.
frame
- the frame to closeMethod Detail |
public void windowClosing(java.awt.event.WindowEvent e)
Details: This method responds to the Frame
's windowClosing
WindowEvent
and is called by the AWT subsystem. Clients should not call this method.
windowClosing
in class java.awt.event.WindowAdapter
|
Sharkysoft home | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |