Java Code Examples for java.awt.Frame#ICONIFIED

The following examples show how to use java.awt.Frame#ICONIFIED . 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
private void hideWindow() {
    Window[] windows = mainWindow.getOwnedWindows();
    for (Window window : windows) {
        if (window.isVisible() && window instanceof Dialog)
            if (((Dialog)window).isModal()) {
                trayPopup.setEnabled(false);
                DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
                        Bundle.SysTray_ModalDialog(), NotifyDescriptor.WARNING_MESSAGE));
                trayPopup.setEnabled(true);
                return;
            }
    }

    mainWindow.setVisible(false);
    if (!Utilities.isWindows() && (mainWindow.getExtendedState() & Frame.ICONIFIED) != 0) {
        workaround = true;
    }
    if (showHideItem != null) showHideItem.setLabel(Bundle.SysTray_Show());
}
 
Example 2
Source File: BETitlePane.java    From beautyeye with Apache License 2.0 6 votes vote down vote up
/**
 * Restores the Frame size.
 */
private void restore()
{
	Frame frame = getFrame();

	if (frame == null)
	{
		return;
	}

	if ((state & Frame.ICONIFIED) != 0)
	{
		frame.setExtendedState(state & ~Frame.ICONIFIED);
	}
	else
	{
		frame.setExtendedState(state & ~Frame.MAXIMIZED_BOTH);
	}
}
 
Example 3
Source File: InputContext.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
private synchronized void notifyClientWindowChange(Window window) {
    if (inputMethod == null) {
        return;
    }

    // if the window is invisible or iconified, send null to the input method.
    if (!window.isVisible() ||
        ((window instanceof Frame) && ((Frame)window).getState() == Frame.ICONIFIED)) {
        clientWindowLocation = null;
        inputMethod.notifyClientWindowChange(null);
        return;
    }
    Rectangle location = window.getBounds();
    if (clientWindowLocation == null || !clientWindowLocation.equals(location)) {
        clientWindowLocation = location;
        inputMethod.notifyClientWindowChange(clientWindowLocation);
    }
}
 
Example 4
Source File: InputContext.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private synchronized void notifyClientWindowChange(Window window) {
    if (inputMethod == null) {
        return;
    }

    // if the window is invisible or iconified, send null to the input method.
    if (!window.isVisible() ||
        ((window instanceof Frame) && ((Frame)window).getState() == Frame.ICONIFIED)) {
        clientWindowLocation = null;
        inputMethod.notifyClientWindowChange(null);
        return;
    }
    Rectangle location = window.getBounds();
    if (clientWindowLocation == null || !clientWindowLocation.equals(location)) {
        clientWindowLocation = location;
        inputMethod.notifyClientWindowChange(clientWindowLocation);
    }
}
 
Example 5
Source File: InputContext.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private synchronized void notifyClientWindowChange(Window window) {
    if (inputMethod == null) {
        return;
    }

    // if the window is invisible or iconified, send null to the input method.
    if (!window.isVisible() ||
        ((window instanceof Frame) && ((Frame)window).getState() == Frame.ICONIFIED)) {
        clientWindowLocation = null;
        inputMethod.notifyClientWindowChange(null);
        return;
    }
    Rectangle location = window.getBounds();
    if (clientWindowLocation == null || !clientWindowLocation.equals(location)) {
        clientWindowLocation = location;
        inputMethod.notifyClientWindowChange(clientWindowLocation);
    }
}
 
Example 6
Source File: XFramePeer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
void changeState(int newState) {
    int changed = state ^ newState;
    int changeIconic = changed & Frame.ICONIFIED;
    boolean iconic = (newState & Frame.ICONIFIED) != 0;
    if (stateLog.isLoggable(PlatformLogger.Level.FINER)) {
        stateLog.finer("Changing state, old state {0}, new state {1}(iconic {2})",
                   Integer.valueOf(state), Integer.valueOf(newState), Boolean.valueOf(iconic));
    }
    if (changeIconic != 0 && iconic) {
        if (stateLog.isLoggable(PlatformLogger.Level.FINER)) {
            stateLog.finer("Iconifying shell " + getShell() + ", this " + this + ", screen " + getScreenNumber());
        }
        XToolkit.awtLock();
        try {
            int res = XlibWrapper.XIconifyWindow(XToolkit.getDisplay(), getShell(), getScreenNumber());
            if (stateLog.isLoggable(PlatformLogger.Level.FINER)) {
                stateLog.finer("XIconifyWindow returned " + res);
            }
        }
        finally {
            XToolkit.awtUnlock();
        }
    }
    if ((changed & ~Frame.ICONIFIED) != 0) {
        setExtendedState(newState);
    }
    if (changeIconic != 0 && !iconic) {
        if (stateLog.isLoggable(PlatformLogger.Level.FINER)) {
            stateLog.finer("DeIconifying " + this);
        }

        XNETProtocol net_protocol = XWM.getWM().getNETProtocol();
        if (net_protocol != null) {
            net_protocol.setActiveWindow(this);
        }
        xSetVisible(true);
    }
}
 
Example 7
Source File: XWM.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
int getState(XDecoratedPeer window) {
    int res = 0;
    final int wm_state = window.getWMState();
    if (wm_state == XUtilConstants.IconicState) {
        res = Frame.ICONIFIED;
    } else {
        res = Frame.NORMAL;
    }
    res |= getExtendedState(window);
    return res;
}
 
Example 8
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 9
Source File: XFramePeer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
void changeState(int newState) {
    int changed = state ^ newState;
    int changeIconic = changed & Frame.ICONIFIED;
    boolean iconic = (newState & Frame.ICONIFIED) != 0;
    if (stateLog.isLoggable(PlatformLogger.Level.FINER)) {
        stateLog.finer("Changing state, old state {0}, new state {1}(iconic {2})",
                   Integer.valueOf(state), Integer.valueOf(newState), Boolean.valueOf(iconic));
    }
    if (changeIconic != 0 && iconic) {
        if (stateLog.isLoggable(PlatformLogger.Level.FINER)) {
            stateLog.finer("Iconifying shell " + getShell() + ", this " + this + ", screen " + getScreenNumber());
        }
        XToolkit.awtLock();
        try {
            int res = XlibWrapper.XIconifyWindow(XToolkit.getDisplay(), getShell(), getScreenNumber());
            if (stateLog.isLoggable(PlatformLogger.Level.FINER)) {
                stateLog.finer("XIconifyWindow returned " + res);
            }
        }
        finally {
            XToolkit.awtUnlock();
        }
    }
    if ((changed & ~Frame.ICONIFIED) != 0) {
        setExtendedState(newState);
    }
    if (changeIconic != 0 && !iconic) {
        if (stateLog.isLoggable(PlatformLogger.Level.FINER)) {
            stateLog.finer("DeIconifying " + this);
        }

        XNETProtocol net_protocol = XWM.getWM().getNETProtocol();
        if (net_protocol != null) {
            net_protocol.setActiveWindow(this);
        }
        xSetVisible(true);
    }
}
 
Example 10
Source File: XWM.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
int getState(XDecoratedPeer window) {
    int res = 0;
    final int wm_state = window.getWMState();
    if (wm_state == XUtilConstants.IconicState) {
        res = Frame.ICONIFIED;
    } else {
        res = Frame.NORMAL;
    }
    res |= getExtendedState(window);
    return res;
}
 
Example 11
Source File: XFramePeer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
void setupState(boolean onInit) {
    if (onInit) {
        state = winAttr.initialState;
    }
    if ((state & Frame.ICONIFIED) != 0) {
        setInitialState(XUtilConstants.IconicState);
    } else {
        setInitialState(XUtilConstants.NormalState);
    }
    setExtendedState(state);
}
 
Example 12
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 13
Source File: XFramePeer.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
void setupState(boolean onInit) {
    if (onInit) {
        state = winAttr.initialState;
    }
    if ((state & Frame.ICONIFIED) != 0) {
        setInitialState(XUtilConstants.IconicState);
    } else {
        setInitialState(XUtilConstants.NormalState);
    }
    setExtendedState(state);
}
 
Example 14
Source File: _AppMenuBarHandler.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
static boolean isFrameMinimized(final Frame frame) {
    return (frame.getExtendedState() & Frame.ICONIFIED) != 0;
}
 
Example 15
Source File: XFramePeer.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public void handlePropertyNotify(XEvent xev) {
    super.handlePropertyNotify(xev);
    XPropertyEvent ev = xev.get_xproperty();

    if (log.isLoggable(PlatformLogger.Level.FINER)) {
        log.finer("Property change {0}", ev);
    }
    /*
     * Let's see if this is a window state protocol message, and
     * if it is - decode a new state in terms of java constants.
     */
    if (!XWM.getWM().isStateChange(this, ev)) {
        stateLog.finer("either not a state atom or state has not been changed");
        return;
    }

    final int newState = XWM.getWM().getState(this);
    int changed = state ^ newState;
    if (changed == 0) {
        if (stateLog.isLoggable(PlatformLogger.Level.FINER)) {
            stateLog.finer("State is the same: " + state);
        }
        return;
    }

    int old_state = state;
    state = newState;

    // sync target with peer
    AWTAccessor.getFrameAccessor().setExtendedState((Frame)target, state);

    if ((changed & Frame.ICONIFIED) != 0) {
        if ((state & Frame.ICONIFIED) != 0) {
            stateLog.finer("Iconified");
            handleIconify();
        } else {
            stateLog.finer("DeIconified");
            content.purgeIconifiedExposeEvents();
            handleDeiconify();
        }
    }
    handleStateChange(old_state, state);
}
 
Example 16
Source File: Central.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** */
public void activateModeTopComponent(ModeImpl mode, TopComponent tc) {
    if(!getModeOpenedTopComponents(mode).contains(tc)) {
        return;
    }
    
    ModeImpl oldActiveMode = getActiveMode();
    //#45650 -some API users call the activation all over again all the time on one item.
    // improve performance for such cases.
    if (oldActiveMode != null && oldActiveMode.equals(mode)) {
        if (tc != null && tc.equals(model.getModeSelectedTopComponent(mode))) {
            // #82385, #139319 do repeat activation if focus is not
            // owned by tc to be activated
            Component fOwn = KeyboardFocusManager.getCurrentKeyboardFocusManager().
                    getFocusOwner();
            if (fOwn != null && SwingUtilities.isDescendingFrom(fOwn, tc)) {
                //#70173 - activation request came probably from a sliding
                //window in 'hover' mode, so let's hide it
                slideOutSlidingWindows( mode );
                return;
            }
        }
    }
    model.setActiveMode(mode);
    model.setModeSelectedTopComponent(mode, tc);
    
    if(isVisible()) {
        viewRequestor.scheduleRequest(new ViewRequest(mode, 
            View.CHANGE_TOPCOMPONENT_ACTIVATED, null, tc));

        //restore floating windows if iconified
        if( mode.getState() == Constants.MODE_STATE_SEPARATED ) {
            Frame frame = (Frame) SwingUtilities.getAncestorOfClass(Frame.class, tc);
            if( null != frame && frame != WindowManagerImpl.getInstance().getMainWindow()
                    && (frame.getExtendedState() & Frame.ICONIFIED) > 0 ) {
                frame.setExtendedState(frame.getExtendedState() - Frame.ICONIFIED );
            }
        }
    }
    
    // Notify registry.
    WindowManagerImpl.notifyRegistryTopComponentActivated(tc);
    
    if(oldActiveMode != mode) {
        WindowManagerImpl.getInstance().doFirePropertyChange(
            WindowManagerImpl.PROP_ACTIVE_MODE, oldActiveMode, mode);
    }
}
 
Example 17
Source File: NormalToIconifiedTest.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
public static void main(String[] args) {
    Robot robot = Util.createRobot();

    Frame testFrame = new Frame("Test Frame");
    testFrame.setSize(200, 200);
    testFrame.addWindowStateListener(new WindowStateListener() {
        @Override
        public void windowStateChanged(WindowEvent e) {
            listenerNotified.set(true);
            synchronized (listenerNotified) {
                listenerNotified.notifyAll();
            }
        }
    });
    testFrame.setVisible(true);

    Frame mainFrame = new Frame("Main Frame");
    mainFrame.setSize(200, 200);
    mainFrame.setLocationRelativeTo(null);
    mainFrame.setVisible(true);

    Util.waitForIdle(robot);

    try {
        Util.clickOnComp(mainFrame, robot);
        Util.waitForIdle(robot);

        // NORMAL -> ICONIFIED
        listenerNotified.set(false);
        testFrame.setExtendedState(Frame.ICONIFIED);
        Util.waitForIdle(robot);

        Util.waitForCondition(listenerNotified, 2000);
        if (!listenerNotified.get()) {
            throw new RuntimeException("Test FAILED! Window state listener was not notified during NORMAL to" +
                    "ICONIFIED transition");
        }
        if (testFrame.getExtendedState() != Frame.ICONIFIED) {
            throw new RuntimeException("Test FAILED! Frame is not in ICONIFIED state");
        }

        // ICONIFIED -> NORMAL
        listenerNotified.set(false);
        testFrame.setExtendedState(Frame.NORMAL);
        Util.waitForIdle(robot);

        Util.waitForCondition(listenerNotified, 2000);
        if (!listenerNotified.get()) {
            throw new RuntimeException("Test FAILED! Window state listener was not notified during ICONIFIED to" +
                    "NORMAL transition");
        }
        if (testFrame.getExtendedState() != Frame.NORMAL) {
            throw new RuntimeException("Test FAILED! Frame is not in NORMAL state");
        }
    } finally {
        testFrame.dispose();
        mainFrame.dispose();
    }
}
 
Example 18
Source File: SysTray.java    From visualvm with GNU General Public License v2.0 4 votes vote down vote up
private void toggleHideWhenMinimized() {
    hideWhenMinimized = hideMinimizedItem.getState();
    if (hideWhenMinimized && (mainWindow.getExtendedState() & Frame.ICONIFIED) != 0)
        hideWindow(); // May not hide window when modal dialog(s) in the way
    SysTrayPreferences.getInstance().setHideWhenMinimized(hideWhenMinimized);
}
 
Example 19
Source File: XFramePeer.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void handlePropertyNotify(XEvent xev) {
    super.handlePropertyNotify(xev);
    XPropertyEvent ev = xev.get_xproperty();

    if (log.isLoggable(PlatformLogger.Level.FINER)) {
        log.finer("Property change {0}", ev);
    }
    /*
     * Let's see if this is a window state protocol message, and
     * if it is - decode a new state in terms of java constants.
     */
    if (!XWM.getWM().isStateChange(this, ev)) {
        stateLog.finer("either not a state atom or state has not been changed");
        return;
    }

    final int newState = XWM.getWM().getState(this);
    int changed = state ^ newState;
    if (changed == 0) {
        if (stateLog.isLoggable(PlatformLogger.Level.FINER)) {
            stateLog.finer("State is the same: " + state);
        }
        return;
    }

    int old_state = state;
    state = newState;

    // sync target with peer
    AWTAccessor.getFrameAccessor().setExtendedState((Frame)target, state);

    if ((changed & Frame.ICONIFIED) != 0) {
        if ((state & Frame.ICONIFIED) != 0) {
            stateLog.finer("Iconified");
            handleIconify();
        } else {
            stateLog.finer("DeIconified");
            content.purgeIconifiedExposeEvents();
            handleDeiconify();
        }
    }
    handleStateChange(old_state, state);
}
 
Example 20
Source File: _AppMenuBarHandler.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
static boolean isFrameMinimized(final Frame frame) {
    return (frame.getExtendedState() & Frame.ICONIFIED) != 0;
}