Java Swing Tutorial - Java WindowAdapter .windowIconified (WindowEvent e)








Syntax

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

public void windowIconified(WindowEvent e)

Example

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

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);/*from  www.j  av  a2 s . co m*/
    window.addWindowListener(new WindowHandler());
    window.setVisible(true);
  }
  class WindowHandler extends WindowAdapter {
    public void windowIconified(WindowEvent e) {
      System.out.println("windowIconified");
      window.dispose(); // Release the window resources
      System.exit(0); // End the application
    }
  }
  public static void main(String[] args) {
    new Main();
  }
}