Java AWT WindowStateListener handle window state change event
import java.awt.event.WindowEvent; import java.awt.event.WindowStateListener; import javax.swing.JFrame; class My implements WindowStateListener { public void windowStateChanged(WindowEvent e) { System.out.println("WindowStateListener method called: windowStateChanged."); }/*from w w w. j a va2s .c o m*/ } public class Main { public static void main(String[] args) { JFrame window = new JFrame("java2s.com"); window.setBounds(30, 30, 300, 300); window.addWindowStateListener(new My()); window.setVisible(true); } }