Created
July 12, 2014 16:37
-
-
Save juancarloscruzd/79f9d828f3cc10bb1ab6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.awt.event.WindowAdapter; | |
import java.awt.event.WindowEvent; | |
import javax.swing.JFrame; | |
public class Main extends JFrame { | |
public Main() { | |
setSize(300, 300); | |
setTitle("Window Listener"); | |
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | |
this.addWindowListener(new WindowAdapter() { | |
public void windowOpened(WindowEvent e) { | |
System.out.println("Window Opened Event"); | |
} | |
public void windowClosing(WindowEvent e) { | |
System.out.println("Window Closing Event"); | |
} | |
public void windowClosed(WindowEvent e) { | |
System.out.println("Window Close Event"); | |
} | |
public void windowIconified(WindowEvent e) { | |
System.out.println("Window Iconified Event"); | |
} | |
public void windowDeiconified(WindowEvent e) { | |
System.out.println("Window Deiconified Event"); | |
} | |
public void windowActivated(WindowEvent e) { | |
System.out.println("Window Activated Event"); | |
} | |
public void windowDeactivated(WindowEvent e) { | |
System.out.println("Window Deactivated Event"); | |
} | |
public void windowStateChanged(WindowEvent e) { | |
System.out.println("Window State Changed Event"); | |
} | |
public void windowGainedFocus(WindowEvent e) { | |
System.out.println("Window Gained Focus Event"); | |
} | |
public void windowLostFocus(WindowEvent e) { | |
System.out.println("Window Lost Focus Event"); | |
} | |
}); | |
} | |
public static void main(String[] args) { | |
new Main().setVisible(true); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment