Java Code Examples for java.awt.event.WindowEvent#WINDOW_DEACTIVATED
The following examples show how to use
java.awt.event.WindowEvent#WINDOW_DEACTIVATED .
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: DefaultWindowController.java From lnk2pwn with MIT License | 6 votes |
@Override public void eventDispatched(AWTEvent event) { if (event instanceof WindowEvent) { WindowEvent windowEvent = (WindowEvent) event; switch(windowEvent.getID()) { case WindowEvent.WINDOW_ACTIVATED: window = windowEvent.getWindow(); break; case WindowEvent.WINDOW_DEACTIVATED: window = null; break; default: break; } } }
Example 2
Source File: SwingUtils.java From IBC with GNU General Public License v3.0 | 6 votes |
static String windowEventToString(int eventID) { switch (eventID) { case WindowEvent.WINDOW_ACTIVATED: return "Activated"; case WindowEvent.WINDOW_CLOSED: return "Closed"; case WindowEvent.WINDOW_CLOSING: return "Closing"; case WindowEvent.WINDOW_DEACTIVATED: return "Deactivated"; case WindowEvent.WINDOW_DEICONIFIED: return "Deiconified"; case WindowEvent.WINDOW_GAINED_FOCUS: return "Focused"; case WindowEvent.WINDOW_ICONIFIED: return "Iconified"; case WindowEvent.WINDOW_LOST_FOCUS: return "Lost focus"; case WindowEvent.WINDOW_OPENED: return "Opened"; case WindowEvent.WINDOW_STATE_CHANGED: return "State changed"; default: return "???"; } }
Example 3
Source File: Window.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * Processes events on this window. If the event is an * {@code WindowEvent}, it invokes the * {@code processWindowEvent} method, else it invokes its * superclass's {@code processEvent}. * <p>Note that if the event parameter is {@code null} * the behavior is unspecified and may result in an * exception. * * @param e the event */ protected void processEvent(AWTEvent e) { if (e instanceof WindowEvent) { switch (e.getID()) { case WindowEvent.WINDOW_OPENED: case WindowEvent.WINDOW_CLOSING: case WindowEvent.WINDOW_CLOSED: case WindowEvent.WINDOW_ICONIFIED: case WindowEvent.WINDOW_DEICONIFIED: case WindowEvent.WINDOW_ACTIVATED: case WindowEvent.WINDOW_DEACTIVATED: processWindowEvent((WindowEvent)e); break; case WindowEvent.WINDOW_GAINED_FOCUS: case WindowEvent.WINDOW_LOST_FOCUS: processWindowFocusEvent((WindowEvent)e); break; case WindowEvent.WINDOW_STATE_CHANGED: processWindowStateEvent((WindowEvent)e); break; } return; } super.processEvent(e); }
Example 4
Source File: SwingUtils.java From ib-controller with GNU General Public License v3.0 | 6 votes |
static String windowEventToString(int eventID) { switch (eventID) { case WindowEvent.WINDOW_ACTIVATED: return "Activated"; case WindowEvent.WINDOW_CLOSED: return "Closed"; case WindowEvent.WINDOW_CLOSING: return "Closing"; case WindowEvent.WINDOW_DEACTIVATED: return "Deactivated"; case WindowEvent.WINDOW_DEICONIFIED: return "Deiconfied"; case WindowEvent.WINDOW_GAINED_FOCUS: return "Focused"; case WindowEvent.WINDOW_ICONIFIED: return "Iconified"; case WindowEvent.WINDOW_LOST_FOCUS: return "Lost focus"; case WindowEvent.WINDOW_OPENED: return "Opened"; case WindowEvent.WINDOW_STATE_CHANGED: return "State changed"; default: return "???"; } }
Example 5
Source File: NbClipboard.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void eventDispatched(AWTEvent ev) { if (!(ev instanceof WindowEvent)) return; if (ev.getID() == WindowEvent.WINDOW_DEACTIVATED) { lastWindowDeactivated = System.currentTimeMillis(); lastWindowDeactivatedSource = new WeakReference<Object>(ev.getSource()); anyWindowIsActivated = false; if( Utilities.isWindows() ) { //#247585 - even listening to clipboard changes when the window isn't active //may throw a MS Windows error as the 'clipboard copy' action doesn't have enough time to finish systemClipboard.removeFlavorListener(this); } } if (ev.getID() == WindowEvent.WINDOW_ACTIVATED) { if( Utilities.isWindows() ) { systemClipboard.addFlavorListener(this); } anyWindowIsActivated = true; if (System.currentTimeMillis() - lastWindowDeactivated < 100 && ev.getSource() == lastWindowDeactivatedSource.get()) { activateWindowHack (false); } if (log.isLoggable (Level.FINE)) { log.log (Level.FINE, "window activated scheduling update"); // NOI18N } scheduleGetFromSystemClipboard(true); } }
Example 6
Source File: Window.java From Bytecoder with Apache License 2.0 | 5 votes |
boolean eventEnabled(AWTEvent e) { switch(e.id) { case WindowEvent.WINDOW_OPENED: case WindowEvent.WINDOW_CLOSING: case WindowEvent.WINDOW_CLOSED: case WindowEvent.WINDOW_ICONIFIED: case WindowEvent.WINDOW_DEICONIFIED: case WindowEvent.WINDOW_ACTIVATED: case WindowEvent.WINDOW_DEACTIVATED: if ((eventMask & AWTEvent.WINDOW_EVENT_MASK) != 0 || windowListener != null) { return true; } return false; case WindowEvent.WINDOW_GAINED_FOCUS: case WindowEvent.WINDOW_LOST_FOCUS: if ((eventMask & AWTEvent.WINDOW_FOCUS_EVENT_MASK) != 0 || windowFocusListener != null) { return true; } return false; case WindowEvent.WINDOW_STATE_CHANGED: if ((eventMask & AWTEvent.WINDOW_STATE_EVENT_MASK) != 0 || windowStateListener != null) { return true; } return false; default: break; } return super.eventEnabled(e); }
Example 7
Source File: Window.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Processes window events occurring on this window by * dispatching them to any registered WindowListener objects. * NOTE: This method will not be called unless window events * are enabled for this component; this happens when one of the * following occurs: * <ul> * <li>A WindowListener object is registered via * {@code addWindowListener} * <li>Window events are enabled via {@code enableEvents} * </ul> * <p>Note that if the event parameter is {@code null} * the behavior is unspecified and may result in an * exception. * * @param e the window event * @see Component#enableEvents */ protected void processWindowEvent(WindowEvent e) { WindowListener listener = windowListener; if (listener != null) { switch(e.getID()) { case WindowEvent.WINDOW_OPENED: listener.windowOpened(e); break; case WindowEvent.WINDOW_CLOSING: listener.windowClosing(e); break; case WindowEvent.WINDOW_CLOSED: listener.windowClosed(e); break; case WindowEvent.WINDOW_ICONIFIED: listener.windowIconified(e); break; case WindowEvent.WINDOW_DEICONIFIED: listener.windowDeiconified(e); break; case WindowEvent.WINDOW_ACTIVATED: listener.windowActivated(e); break; case WindowEvent.WINDOW_DEACTIVATED: listener.windowDeactivated(e); break; default: break; } } }
Example 8
Source File: UnitSelectorDialog.java From megamek with GNU General Public License v2.0 | 5 votes |
@Override protected void processWindowEvent(WindowEvent e){ super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_DEACTIVATED){ GUIPreferences guip = GUIPreferences.getInstance(); guip.setMechSelectorUnitType(comboUnitType.getSelectedIndex()); guip.setMechSelectorWeightClass(comboWeight.getSelectedIndex()); guip.setMechSelectorRulesLevels(Arrays.toString(lstTechLevel.getSelectedIndices())); guip.setMechSelectorSizeHeight(getSize().height); guip.setMechSelectorSizeWidth(getSize().width); } }
Example 9
Source File: GameOptionsDialog.java From megamek with GNU General Public License v2.0 | 5 votes |
@Override protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_DEACTIVATED) { GUIPreferences guip = GUIPreferences.getInstance(); guip.setGameOptionsSizeHeight(getSize().height); guip.setGameOptionsSizeWidth(getSize().width); } }
Example 10
Source File: ChatWindow.java From tutorials with MIT License | 4 votes |
public void windowStateChanged(WindowEvent event) { if (event.getNewState() == WindowEvent.WINDOW_DEACTIVATED ) { System.gc(); // if it ends up running, great! } }
Example 11
Source File: IdePopupManager.java From consulo with Apache License 2.0 | 4 votes |
@Override public boolean dispatch(@Nonnull final AWTEvent e) { LOG.assertTrue(isPopupActive()); if (e.getID() == WindowEvent.WINDOW_LOST_FOCUS || e.getID() == WindowEvent.WINDOW_DEACTIVATED) { if (!isPopupActive()) return false; Window focused = ((WindowEvent)e).getOppositeWindow(); if (focused == null) { focused = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow(); } Component ultimateParentForFocusedComponent = UIUtil.findUltimateParent(focused); Window sourceWindow = ((WindowEvent)e).getWindow(); Component ultimateParentForEventWindow = UIUtil.findUltimateParent(sourceWindow); boolean shouldCloseAllPopup = false; if (ultimateParentForEventWindow == null || ultimateParentForFocusedComponent == null) { shouldCloseAllPopup = true; } consulo.ui.Window uiWindow = TargetAWT.from((Window)ultimateParentForEventWindow); IdeFrame ultimateParentWindowForEvent = IdeFrameUtil.findRootIdeFrame(uiWindow); if (!shouldCloseAllPopup && ultimateParentWindowForEvent != null) { if (ultimateParentWindowForEvent.isInFullScreen() && !ultimateParentForFocusedComponent.equals(ultimateParentForEventWindow)) { shouldCloseAllPopup = true; } } if (shouldCloseAllPopup) { closeAllPopups(); } } else if (e instanceof KeyEvent) { // the following is copied from IdeKeyEventDispatcher KeyEvent keyEvent = (KeyEvent)e; Object source = keyEvent.getSource(); if (myIgnoreNextKeyTypedEvent) { if (KeyEvent.KEY_TYPED == e.getID()) return true; myIgnoreNextKeyTypedEvent = false; } else if (SystemInfo.isMac && InputEvent.ALT_DOWN_MASK == keyEvent.getModifiersEx() && Registry.is("ide.mac.alt.mnemonic.without.ctrl") && source instanceof Component) { // the myIgnoreNextKeyTypedEvent changes event processing to support Alt-based mnemonics on Mac only if (KeyEvent.KEY_TYPED == e.getID() && !IdeEventQueue.getInstance().isInputMethodEnabled() || IdeKeyEventDispatcher.hasMnemonicInWindow((Component)source, keyEvent)) { myIgnoreNextKeyTypedEvent = true; return false; } } } if (e instanceof KeyEvent || e instanceof MouseEvent) { for (int i = myDispatchStack.size() - 1; i >= 0 && i < myDispatchStack.size(); i--) { final boolean dispatched = myDispatchStack.get(i).dispatch(e); if (dispatched) return true; } } return false; }