import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import javax.swing.JFrame;
public class UsingWindowListener {
public static void main(String[] args) {
JFrame aWindow = new JFrame("This is the Window Title");
aWindow.setBounds(50, 100, 300, 300);
aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
aWindow.addWindowListener(new WindowListener() {
public void windowIconified(WindowEvent e) {
System.out.println(e);
}
public void windowDeiconified(WindowEvent e) {
}
public void windowOpened(WindowEvent e) {
}
public void windowClosing(WindowEvent e) {
}
public void windowClosed(WindowEvent e) {
}
public void windowActivated(WindowEvent e) {
}
public void windowDeactivated(WindowEvent e) {
}
});
aWindow.setVisible(true);
}
}