Java Code Examples for java.awt.event.WindowEvent#getNewState()

The following examples show how to use java.awt.event.WindowEvent#getNewState() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SysTray.java    From visualvm with GNU General Public License v2.0 6 votes vote down vote up
public void windowStateChanged(WindowEvent e) {
    int windowState = e.getNewState();
    if ((windowState & Frame.ICONIFIED) != 0) {
        if (workaround) {
            workaround = false;
            mainWindow.setExtendedState(lastWindowState);
        } else {
            workaround = false;
            if (hideWhenMinimized || hideTrayIcon) hideWindow(); // May not hide window when modal dialog(s) in the way
            if (!mainWindow.isVisible() && hideTrayIcon && trayIcon == null) showTrayIcon();
        }
    } else {
        lastWindowState = windowState;
        if (hideTrayIcon && trayIcon != null) hideTrayIcon();
    }
}
 
Example 2
Source File: PopupUtil.java    From cakephp3-netbeans with Apache License 2.0 6 votes vote down vote up
@Override
        public void windowStateChanged(WindowEvent windowEvent) {
            if (popupWindow != null) {
                int oldState = windowEvent.getOldState();
                int newState = windowEvent.getNewState();

                if (((oldState & Frame.ICONIFIED) == 0)
                        && ((newState & Frame.ICONIFIED) == Frame.ICONIFIED)) {
                    hidePopup();
//                } else if (((oldState & Frame.ICONIFIED) == Frame.ICONIFIED) &&
//                           ((newState & Frame.ICONIFIED) == 0 )) {
//                    //TODO remember we showed before and show again? I guess not worth the efford, not part of spec.
                }
            }

        }
 
Example 3
Source File: DefaultMainWindowManager.java    From IBC with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void windowStateChanged(WindowEvent e) {
    int state = e.getNewState();
    if (((state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH)) {
        if ((Calendar.getInstance().getTimeInMillis() - lastMinimizeTime) < 2000) {
            iconizeIfRequired();
        } else {
            mainWindow.removeWindowStateListener(listener);
        }
    }
}
 
Example 4
Source File: PopupUtil.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void windowStateChanged(WindowEvent windowEvent) {
            if (popupWindow != null ) {
                int oldState = windowEvent.getOldState();
                int newState = windowEvent.getNewState();
            
                if (((oldState & Frame.ICONIFIED) == 0) &&
                    ((newState & Frame.ICONIFIED) == Frame.ICONIFIED)) {
                    hidePopup();
//                } else if (((oldState & Frame.ICONIFIED) == Frame.ICONIFIED) && 
//                           ((newState & Frame.ICONIFIED) == 0 )) {
//                    //TODO remember we showed before and show again? I guess not worth the efford, not part of spec.
                }
            }

        }
 
Example 5
Source File: StatusLineComponent.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public @Override void windowStateChanged(WindowEvent windowEvent) {
            if (showingPopup) {
                int oldState = windowEvent.getOldState();
                int newState = windowEvent.getNewState();
            
                if (((oldState & Frame.ICONIFIED) == 0) &&
                    ((newState & Frame.ICONIFIED) == Frame.ICONIFIED)) {
                    hidePopup();
//                } else if (((oldState & Frame.ICONIFIED) == Frame.ICONIFIED) && 
//                           ((newState & Frame.ICONIFIED) == 0 )) {
//                    //TODO remember we showed before and show again? I guess not worth the efford, not part of spec.
                }
            }

        }
 
Example 6
Source File: PopupUtil.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void windowStateChanged(WindowEvent windowEvent) {
    if (popupWindow != null ) {
        int oldState = windowEvent.getOldState();
        int newState = windowEvent.getNewState();
    
        if (((oldState & Frame.ICONIFIED) == 0) &&
            ((newState & Frame.ICONIFIED) == Frame.ICONIFIED)) {
            hidePopup();
        }
    }

}
 
Example 7
Source File: SymfonyGoToViewActionPopup.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void windowStateChanged(WindowEvent windowEvent) {
    if (popupWindow != null ) {
        int oldState = windowEvent.getOldState();
        int newState = windowEvent.getNewState();
    
        if (((oldState & Frame.ICONIFIED) == 0) &&
            ((newState & Frame.ICONIFIED) == Frame.ICONIFIED)) {
            hide();
        }
    }
}
 
Example 8
Source File: PopupUtil.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void windowStateChanged(WindowEvent windowEvent) {
    if (popupWindow != null) {
        int oldState = windowEvent.getOldState();
        int newState = windowEvent.getNewState();

        if (((oldState & Frame.ICONIFIED) == 0) && ((newState & Frame.ICONIFIED) == Frame.ICONIFIED)) {
            hidePopup();
        }
    }

}
 
Example 9
Source File: PopupUtil.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void windowStateChanged(WindowEvent windowEvent) {
            if (popupWindow != null ) {
                int oldState = windowEvent.getOldState();
                int newState = windowEvent.getNewState();
            
                if (((oldState & Frame.ICONIFIED) == 0) &&
                    ((newState & Frame.ICONIFIED) == Frame.ICONIFIED)) {
                    hidePopup();
//                } else if (((oldState & Frame.ICONIFIED) == Frame.ICONIFIED) && 
//                           ((newState & Frame.ICONIFIED) == 0 )) {
//                    //TODO remember we showed before and show again? I guess not worth the efford, not part of spec.
                }
            }

        }
 
Example 10
Source File: PopupUtil.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void windowStateChanged(WindowEvent windowEvent) {
            if (popupWindow != null ) {
                int oldState = windowEvent.getOldState();
                int newState = windowEvent.getNewState();
            
                if (((oldState & Frame.ICONIFIED) == 0) &&
                    ((newState & Frame.ICONIFIED) == Frame.ICONIFIED)) {
                    hidePopup();
//                } else if (((oldState & Frame.ICONIFIED) == Frame.ICONIFIED) && 
//                           ((newState & Frame.ICONIFIED) == 0 )) {
//                    //TODO remember we showed before and show again? I guess not worth the efford, not part of spec.
                }
            }

        }
 
Example 11
Source File: PopupUtil.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void windowStateChanged(WindowEvent windowEvent) {
            if (popupWindow != null ) {
                int oldState = windowEvent.getOldState();
                int newState = windowEvent.getNewState();
            
                if (((oldState & Frame.ICONIFIED) == 0) &&
                    ((newState & Frame.ICONIFIED) == Frame.ICONIFIED)) {
                    hidePopup();
//                } else if (((oldState & Frame.ICONIFIED) == Frame.ICONIFIED) && 
//                           ((newState & Frame.ICONIFIED) == 0 )) {
//                    //TODO remember we showed before and show again? I guess not worth the efford, not part of spec.
                }
            }

        }
 
Example 12
Source File: LuckWindowAdapter.java    From littleluck with Apache License 2.0 5 votes vote down vote up
public void windowStateChanged(WindowEvent e)
{
    Window window = (Window) e.getSource();

    if (window instanceof JFrame)
    {
        JFrame frame = (JFrame) window;

        JRootPane rootPane = frame.getRootPane();

        if(rootPane.getUI() instanceof LuckRootPaneUI)
        {
            LuckRootPaneUI rootPaneUI = (LuckRootPaneUI) rootPane.getUI();

            rootPaneUI.getTitlePane().setState(e.getNewState());
        }

        if (e.getNewState() == JFrame.MAXIMIZED_BOTH)
        {
        	rootPane.setBorder(null);
        }
        else if (e.getNewState() == JFrame.NORMAL)
        {
        	rootPane.setBorder(UIManager.getBorder(LuckRootPaneUIBundle.FRAME_BORDER));
        }
    }
}
 
Example 13
Source File: CGraphWindow.java    From binnavi with Apache License 2.0 5 votes vote down vote up
@Override
public void windowStateChanged(final WindowEvent event) {
  if (firstShrinking && event.getNewState() == NORMAL) {
    setSize((int) (getWidth() * 0.75), (int) (getHeight() * 0.75));

    firstShrinking = false;
  }
}
 
Example 14
Source File: MainWindow.java    From FoxTelem with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void windowStateChanged(WindowEvent e) {
	if (e.getNewState() == WindowEvent.WINDOW_LOST_FOCUS) {
		//e.getWindow().setVisible(false);
		Log.println("LOST FOCUS");
	}
	if (e.getNewState() == WindowEvent.WINDOW_ACTIVATED) {
		//e.getWindow().setVisible(false);
		Log.println("ACTIVATED");
	}
	if (e.getNewState() == WindowEvent.WINDOW_GAINED_FOCUS) {
		//e.getWindow().setVisible(false);
		Log.println("GOT FOCUS");
	}
}
 
Example 15
Source File: PFrame.java    From PolyGlot with MIT License 5 votes vote down vote up
/**
 * Used to set frame state of window
 *
 * @param e
 */
private void setWindowState(WindowEvent e) {
    if ((e.getNewState() & Frame.ICONIFIED) == Frame.ICONIFIED) {
        frameState = Frame.ICONIFIED;
    } else if ((e.getNewState() & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH) {
        frameState = Frame.MAXIMIZED_BOTH;
    } else {
        frameState = -1;
    }
}
 
Example 16
Source File: ChatWindow.java    From tutorials with MIT License 4 votes vote down vote up
public void windowStateChanged(WindowEvent event) {
    if (event.getNewState() == WindowEvent.WINDOW_DEACTIVATED ) {
        System.gc(); // if it ends up running, great!
    }
}