Window Events Example

For example, windows don't close on their own. You have to explicitly close them. The following subclass of Frame puts up a window that responds to efforts to close it by calling setVisible(false) and dispose().

import java.awt.*;
import java.awt.event.*;

public class ClosableFrame extends Frame implements WindowListener {

  public ClosableFrame() {
  public ClosableFrame(String title) {
  public void windowClosing(WindowEvent evt) {
  public void windowOpened(WindowEvent evt) {}  
  public void windowClosed(WindowEvent evt) {}
  public void windowIconified(WindowEvent evt) {}
  public void windowDeiconified(WindowEvent evt) {}
  public void windowActivated(WindowEvent evt) {}
  public void windowDeactivated(WindowEvent evt) {}


Previous | Next | Top | Cafe au Lait

Copyright 1997, 1998, 2002 Elliotte Rusty Harold
Last Modified April 1, 2006