Iconification and maximization events for a frame or window can be detected by adding a java.awt.event.WindowStateListener instance to that frame.

 // Create the frame
Frame frame = new Frame();
    
// Create a listener
WindowStateListener listener = new WindowAdapter() {
    public void windowStateChanged(WindowEvent evt) {
        int oldState = evt.getOldState();
        int newState = evt.getNewState();
    
        if ((oldState & Frame.ICONIFIED) == 0
            && (newState & Frame.ICONIFIED) != 0) {
            // Frame was iconized
        } else if ((oldState & Frame.ICONIFIED) != 0
            && (newState & Frame.ICONIFIED) == 0) {
            // Frame was deiconized
        }
    
        if ((oldState & Frame.MAXIMIZED_BOTH) == 0
            && (newState & Frame.MAXIMIZED_BOTH) != 0) {
            // Frame was maximized
        } else if ((oldState & Frame.MAXIMIZED_BOTH) != 0
            && (newState & Frame.MAXIMIZED_BOTH) == 0) {
            // Frame was minimized
        }
    }
};
    
// Register the listener with the frame
frame.addWindowStateListener(listener);