Java WindowAdapter .windowOpened (WindowEvent e)

Syntax

WindowAdapter.windowOpened(WindowEvent e) has the following syntax.

public void windowOpened(WindowEvent e)

Example

In the following code shows how to use WindowAdapter.windowOpened(WindowEvent e) method.


/*from  w w w . j  a  v  a  2 s  .  c  o  m*/
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JFrame;
public class Main {
  JFrame window = new JFrame("Main");
  public Main() {
    window.setBounds(30, 30, 300, 300);
    window.addWindowListener(new WindowHandler());
    window.setVisible(true);
  }
  class WindowHandler extends WindowAdapter {
    public void windowOpened(WindowEvent e) {
      System.out.println("windowOpened");
      window.dispose(); // Release the window resources
      System.exit(0); // End the application
    }
  }
  public static void main(String[] args) {
    new Main();
  }
}




















Home »
  Java Tutorial »
    java.awt.event »




AdjustmentListener
ActionEvent
ActionListener
HierarchyEvent
HierarchyListener
InputEvent
ItemEvent
ItemListener
KeyAdapter
KeyEvent
KeyListener
MouseAdapter
MouseEvent
MouseListener
MouseMotionAdapter
MouseMotionListener
MouseWheelEvent
MouseWheelListener
WindowAdapter
WindowEvent
WindowFocusListener
WindowStateListener