Java JFrame handle window state changed 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 ww . j a v a2s. 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); } }