If you want to return it from iconified , you can simply set its state to normal :
JFrame frame = new JFrame(...); // Show the frame frame.setVisible(true); // Sleep for 5 seconds, then minimize Thread.sleep(5000); frame.setState(java.awt.Frame.ICONIFIED); // Sleep for 5 seconds, then restore Thread.sleep(5000); frame.setState(java.awt.Frame.NORMAL);
An example from here .
There are also WindowEvent s that fire every time the state changes, and the WindowListener that handles these triggers. In this case you can use:
public class YourClass implements WindowListener { ... public void windowDeiconified(WindowEvent e) {
If you want to check for another change in the state of the program, there is no โpure Javaโ solution, but just an ID window.
source share