Java Reference
In-Depth Information
Display 18.1
Methods in the
WindowListener
Interface
The
WindowListener
interface and the
WindowEvent
class are in the package
java.awt.event
.
public void
windowOpened(WindowEvent e)
Invoked when a window is opened.
public void
windowClosing(WindowEvent e)
Invoked when a window is in the process of being closed. Clicking the close-window button
causes an invocation of this method.
public void
windowClosed(WindowEvent e)
Invoked when a window has been closed.
public void
windowIconified(WindowEvent e)
Invoked when a window is iconified. When you click the minimize button in a
JFrame
, it is
iconified.
public void
windowDeiconified(WindowEvent e)
Invoked when a window is deiconified. When you activate a minimized window, it is deiconified.
public void
windowActivated(WindowEvent e)
Invoked when a window is activated. When you click in a window, it becomes the activated
window. Other actions can also activate a window.
public void
windowDeactivated(WindowEvent e)
Invoked when a window is deactivated. When a window is activated, all other windows are
deactivated. Other actions can also deactivate a window.
The
WindowListener
Interface
When the user clicks any of the three standard
JFrame
buttons (for closing the window,
minimizing the window, and resizing the window), it generates a window event. Window
events are sent to window listeners. In order to be a window listener, a class must implement
the
WindowListener
interface. The method headings for the
WindowListener
interface
are given in Display 18.1.