Java Code Examples for javax.swing.MenuSelectionManager#setSelectedPath()
The following examples show how to use
javax.swing.MenuSelectionManager#setSelectedPath() .
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: SeaGlassCheckBoxMenuItemUI.java From seaglass with Apache License 2.0 | 6 votes |
public void processMouseEvent(JMenuItem item, MouseEvent e, MenuElement path[], MenuSelectionManager manager) { Point p = e.getPoint(); if (p.x >= 0 && p.x < item.getWidth() && p.y >= 0 && p.y < item.getHeight()) { if (e.getID() == MouseEvent.MOUSE_RELEASED) { manager.clearSelectedPath(); item.doClick(0); } else { manager.setSelectedPath(path); } } else if (item.getModel().isArmed()) { int c = path.length - 1; MenuElement newPath[] = new MenuElement[c]; for (int i = 0; i < c; i++) { newPath[i] = path[i]; } manager.setSelectedPath(newPath); } }
Example 2
Source File: SeaGlassRadioButtonMenuItemUI.java From seaglass with Apache License 2.0 | 6 votes |
public void processMouseEvent(JMenuItem item, MouseEvent e, MenuElement path[], MenuSelectionManager manager) { Point p = e.getPoint(); if (p.x >= 0 && p.x < item.getWidth() && p.y >= 0 && p.y < item.getHeight()) { if (e.getID() == MouseEvent.MOUSE_RELEASED) { manager.clearSelectedPath(); item.doClick(0); item.setArmed(false); } else manager.setSelectedPath(path); } else if (item.getModel().isArmed()) { MenuElement newPath[] = new MenuElement[path.length - 1]; int i, c; for (i = 0, c = path.length - 1; i < c; i++) newPath[i] = path[i]; manager.setSelectedPath(newPath); } }
Example 3
Source File: StayOpenPopupMenu.java From netbeans with Apache License 2.0 | 6 votes |
public void processKeyEvent(KeyEvent e, MenuElement[] path, MenuSelectionManager manager) { if (isReturnAction(e)) { // Handle SPACE and ENTER MenuElement[] p = manager.getSelectedPath(); MenuElement m = p != null && p.length > 0 ? p[p.length - 1] : null; if (m instanceof StayOpen) { e.consume(); if (e.getID() == KeyEvent.KEY_PRESSED) performAction((StayOpen)m, e.getModifiers()); return; } } else for (Component component : getComponents()) { // Handle mnemonics and accelerators if (component instanceof StayOpen) { StayOpen item = (StayOpen)component; JMenuItem i = item.getItem(); KeyStroke k = KeyStroke.getKeyStrokeForEvent(e); if (k.equals(mnemonic(i)) || k.equals(i.getAccelerator())) { e.consume(); manager.setSelectedPath(new MenuElement[] { this, i }); performAction(item, e.getModifiers()); return; } } } super.processKeyEvent(e, path, manager); }
Example 4
Source File: StayOpenPopupMenu.java From visualvm with GNU General Public License v2.0 | 6 votes |
public void processKeyEvent(KeyEvent e, MenuElement[] path, MenuSelectionManager manager) { if (isReturnAction(e)) { // Handle SPACE and ENTER MenuElement[] p = manager.getSelectedPath(); MenuElement m = p != null && p.length > 0 ? p[p.length - 1] : null; if (m instanceof StayOpen) { e.consume(); if (e.getID() == KeyEvent.KEY_PRESSED) performAction((StayOpen)m, e.getModifiers()); return; } } else for (Component component : getComponents()) { // Handle mnemonics and accelerators if (component instanceof StayOpen) { StayOpen item = (StayOpen)component; JMenuItem i = item.getItem(); KeyStroke k = KeyStroke.getKeyStrokeForEvent(e); if (k.equals(mnemonic(i)) || k.equals(i.getAccelerator())) { e.consume(); manager.setSelectedPath(new MenuElement[] { this, i }); performAction(item, e.getModifiers()); return; } } } super.processKeyEvent(e, path, manager); }
Example 5
Source File: MenuButton.java From visualvm with GNU General Public License v2.0 | 5 votes |
private void showHover() { originalConsumeEvent = UIManager.get(CONSUME_EVENT_KEY); UIManager.put(CONSUME_EVENT_KEY, Boolean.FALSE); MenuSelectionManager msm = MenuSelectionManager.defaultManager(); msm.setSelectedPath(new MenuElement[] { MenuButton.this }); if (!listening) { msm.addChangeListener(this); listening = true; } repaint(); }
Example 6
Source File: WindowsRootPaneUI.java From hottub with GNU General Public License v2.0 | 4 votes |
void altReleased(KeyEvent ev) { if (menuCanceledOnPress) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); return; } MenuSelectionManager msm = MenuSelectionManager.defaultManager(); if (msm.getSelectedPath().length == 0) { // if no menu is active, we try activating the menubar JMenuBar mbar = root != null ? root.getJMenuBar() : null; if(mbar == null && winAncestor instanceof JFrame) { mbar = ((JFrame)winAncestor).getJMenuBar(); } JMenu menu = mbar != null ? mbar.getMenu(0) : null; // It might happen that the altRelease event is processed // with a reasonable delay since it has been generated. // Here we check the last deactivation time of the containing // window. If this time appears to be greater than the altRelease // event time the event is skipped to avoid unexpected menu // activation. See 7121442. // Also we must ensure that original source of key event belongs // to the same window object as winAncestor. See 8001633. boolean skip = false; Toolkit tk = Toolkit.getDefaultToolkit(); if (tk instanceof SunToolkit) { Component originalSource = AWTAccessor.getKeyEventAccessor() .getOriginalSource(ev); skip = SunToolkit.getContainingWindow(originalSource) != winAncestor || ev.getWhen() <= ((SunToolkit) tk).getWindowDeactivationTime(winAncestor); } if (menu != null && !skip) { MenuElement[] path = new MenuElement[2]; path[0] = mbar; path[1] = menu; msm.setSelectedPath(path); } else if(!WindowsLookAndFeel.isMnemonicHidden()) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } else { if((msm.getSelectedPath())[0] instanceof ComboPopup) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } }
Example 7
Source File: WindowsRootPaneUI.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 4 votes |
void altReleased(KeyEvent ev) { if (menuCanceledOnPress) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); return; } MenuSelectionManager msm = MenuSelectionManager.defaultManager(); if (msm.getSelectedPath().length == 0) { // if no menu is active, we try activating the menubar JMenuBar mbar = root != null ? root.getJMenuBar() : null; if(mbar == null && winAncestor instanceof JFrame) { mbar = ((JFrame)winAncestor).getJMenuBar(); } JMenu menu = mbar != null ? mbar.getMenu(0) : null; // It might happen that the altRelease event is processed // with a reasonable delay since it has been generated. // Here we check the last deactivation time of the containing // window. If this time appears to be greater than the altRelease // event time the event is skipped to avoid unexpected menu // activation. See 7121442. // Also we must ensure that original source of key event belongs // to the same window object as winAncestor. See 8001633. boolean skip = false; Toolkit tk = Toolkit.getDefaultToolkit(); if (tk instanceof SunToolkit) { Component originalSource = AWTAccessor.getKeyEventAccessor() .getOriginalSource(ev); skip = SunToolkit.getContainingWindow(originalSource) != winAncestor || ev.getWhen() <= ((SunToolkit) tk).getWindowDeactivationTime(winAncestor); } if (menu != null && !skip) { MenuElement[] path = new MenuElement[2]; path[0] = mbar; path[1] = menu; msm.setSelectedPath(path); } else if(!WindowsLookAndFeel.isMnemonicHidden()) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } else { if((msm.getSelectedPath())[0] instanceof ComboPopup) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } }
Example 8
Source File: WindowsRootPaneUI.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
void altReleased(KeyEvent ev) { if (menuCanceledOnPress) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); return; } MenuSelectionManager msm = MenuSelectionManager.defaultManager(); if (msm.getSelectedPath().length == 0) { // if no menu is active, we try activating the menubar JMenuBar mbar = root != null ? root.getJMenuBar() : null; if(mbar == null && winAncestor instanceof JFrame) { mbar = ((JFrame)winAncestor).getJMenuBar(); } JMenu menu = mbar != null ? mbar.getMenu(0) : null; // It might happen that the altRelease event is processed // with a reasonable delay since it has been generated. // Here we check the last deactivation time of the containing // window. If this time appears to be greater than the altRelease // event time the event is skipped to avoid unexpected menu // activation. See 7121442. // Also we must ensure that original source of key event belongs // to the same window object as winAncestor. See 8001633. boolean skip = false; Toolkit tk = Toolkit.getDefaultToolkit(); if (tk instanceof SunToolkit) { Component originalSource = AWTAccessor.getKeyEventAccessor() .getOriginalSource(ev); skip = SunToolkit.getContainingWindow(originalSource) != winAncestor || ev.getWhen() <= ((SunToolkit) tk).getWindowDeactivationTime(winAncestor); } if (menu != null && !skip) { MenuElement[] path = new MenuElement[2]; path[0] = mbar; path[1] = menu; msm.setSelectedPath(path); } else if(!WindowsLookAndFeel.isMnemonicHidden()) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } else { if((msm.getSelectedPath())[0] instanceof ComboPopup) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } }
Example 9
Source File: WindowsRootPaneUI.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
void altReleased(KeyEvent ev) { if (menuCanceledOnPress) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); return; } MenuSelectionManager msm = MenuSelectionManager.defaultManager(); if (msm.getSelectedPath().length == 0) { // if no menu is active, we try activating the menubar JMenuBar mbar = root != null ? root.getJMenuBar() : null; if(mbar == null && winAncestor instanceof JFrame) { mbar = ((JFrame)winAncestor).getJMenuBar(); } JMenu menu = mbar != null ? mbar.getMenu(0) : null; // It might happen that the altRelease event is processed // with a reasonable delay since it has been generated. // Here we check the last deactivation time of the containing // window. If this time appears to be greater than the altRelease // event time the event is skipped to avoid unexpected menu // activation. See 7121442. // Also we must ensure that original source of key event belongs // to the same window object as winAncestor. See 8001633. boolean skip = false; Toolkit tk = Toolkit.getDefaultToolkit(); if (tk instanceof SunToolkit) { Component originalSource = AWTAccessor.getKeyEventAccessor() .getOriginalSource(ev); skip = SunToolkit.getContainingWindow(originalSource) != winAncestor || ev.getWhen() <= ((SunToolkit) tk).getWindowDeactivationTime(winAncestor); } if (menu != null && !skip) { MenuElement[] path = new MenuElement[2]; path[0] = mbar; path[1] = menu; msm.setSelectedPath(path); } else if(!WindowsLookAndFeel.isMnemonicHidden()) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } else { if((msm.getSelectedPath())[0] instanceof ComboPopup) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } }
Example 10
Source File: WindowsRootPaneUI.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
void altReleased(KeyEvent ev) { if (menuCanceledOnPress) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); return; } MenuSelectionManager msm = MenuSelectionManager.defaultManager(); if (msm.getSelectedPath().length == 0) { // if no menu is active, we try activating the menubar JMenuBar mbar = root != null ? root.getJMenuBar() : null; if(mbar == null && winAncestor instanceof JFrame) { mbar = ((JFrame)winAncestor).getJMenuBar(); } JMenu menu = mbar != null ? mbar.getMenu(0) : null; // It might happen that the altRelease event is processed // with a reasonable delay since it has been generated. // Here we check the last deactivation time of the containing // window. If this time appears to be greater than the altRelease // event time the event is skipped to avoid unexpected menu // activation. See 7121442. // Also we must ensure that original source of key event belongs // to the same window object as winAncestor. See 8001633. boolean skip = false; Toolkit tk = Toolkit.getDefaultToolkit(); if (tk instanceof SunToolkit) { Component originalSource = AWTAccessor.getKeyEventAccessor() .getOriginalSource(ev); skip = SunToolkit.getContainingWindow(originalSource) != winAncestor || ev.getWhen() <= ((SunToolkit) tk).getWindowDeactivationTime(winAncestor); } if (menu != null && !skip) { MenuElement[] path = new MenuElement[2]; path[0] = mbar; path[1] = menu; msm.setSelectedPath(path); } else if(!WindowsLookAndFeel.isMnemonicHidden()) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } else { if((msm.getSelectedPath())[0] instanceof ComboPopup) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } }
Example 11
Source File: WindowsRootPaneUI.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
void altReleased(KeyEvent ev) { if (menuCanceledOnPress) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); return; } MenuSelectionManager msm = MenuSelectionManager.defaultManager(); if (msm.getSelectedPath().length == 0) { // if no menu is active, we try activating the menubar JMenuBar mbar = root != null ? root.getJMenuBar() : null; if(mbar == null && winAncestor instanceof JFrame) { mbar = ((JFrame)winAncestor).getJMenuBar(); } JMenu menu = mbar != null ? mbar.getMenu(0) : null; // It might happen that the altRelease event is processed // with a reasonable delay since it has been generated. // Here we check the last deactivation time of the containing // window. If this time appears to be greater than the altRelease // event time the event is skipped to avoid unexpected menu // activation. See 7121442. // Also we must ensure that original source of key event belongs // to the same window object as winAncestor. See 8001633. boolean skip = false; Toolkit tk = Toolkit.getDefaultToolkit(); if (tk instanceof SunToolkit) { Component originalSource = AWTAccessor.getKeyEventAccessor() .getOriginalSource(ev); skip = SunToolkit.getContainingWindow(originalSource) != winAncestor || ev.getWhen() <= ((SunToolkit) tk).getWindowDeactivationTime(winAncestor); } if (menu != null && !skip) { MenuElement[] path = new MenuElement[2]; path[0] = mbar; path[1] = menu; msm.setSelectedPath(path); } else if(!WindowsLookAndFeel.isMnemonicHidden()) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } else { if((msm.getSelectedPath())[0] instanceof ComboPopup) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } }
Example 12
Source File: WindowsRootPaneUI.java From jdk1.8-source-analysis with Apache License 2.0 | 4 votes |
void altReleased(KeyEvent ev) { if (menuCanceledOnPress) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); return; } MenuSelectionManager msm = MenuSelectionManager.defaultManager(); if (msm.getSelectedPath().length == 0) { // if no menu is active, we try activating the menubar JMenuBar mbar = root != null ? root.getJMenuBar() : null; if(mbar == null && winAncestor instanceof JFrame) { mbar = ((JFrame)winAncestor).getJMenuBar(); } JMenu menu = mbar != null ? mbar.getMenu(0) : null; // It might happen that the altRelease event is processed // with a reasonable delay since it has been generated. // Here we check the last deactivation time of the containing // window. If this time appears to be greater than the altRelease // event time the event is skipped to avoid unexpected menu // activation. See 7121442. // Also we must ensure that original source of key event belongs // to the same window object as winAncestor. See 8001633. boolean skip = false; Toolkit tk = Toolkit.getDefaultToolkit(); if (tk instanceof SunToolkit) { Component originalSource = AWTAccessor.getKeyEventAccessor() .getOriginalSource(ev); skip = SunToolkit.getContainingWindow(originalSource) != winAncestor || ev.getWhen() <= ((SunToolkit) tk).getWindowDeactivationTime(winAncestor); } if (menu != null && !skip) { MenuElement[] path = new MenuElement[2]; path[0] = mbar; path[1] = menu; msm.setSelectedPath(path); } else if(!WindowsLookAndFeel.isMnemonicHidden()) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } else { if((msm.getSelectedPath())[0] instanceof ComboPopup) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } }
Example 13
Source File: WindowsRootPaneUI.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
void altReleased(KeyEvent ev) { if (menuCanceledOnPress) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); return; } MenuSelectionManager msm = MenuSelectionManager.defaultManager(); if (msm.getSelectedPath().length == 0) { // if no menu is active, we try activating the menubar JMenuBar mbar = root != null ? root.getJMenuBar() : null; if(mbar == null && winAncestor instanceof JFrame) { mbar = ((JFrame)winAncestor).getJMenuBar(); } JMenu menu = mbar != null ? mbar.getMenu(0) : null; // It might happen that the altRelease event is processed // with a reasonable delay since it has been generated. // Here we check the last deactivation time of the containing // window. If this time appears to be greater than the altRelease // event time the event is skipped to avoid unexpected menu // activation. See 7121442. // Also we must ensure that original source of key event belongs // to the same window object as winAncestor. See 8001633. boolean skip = false; Toolkit tk = Toolkit.getDefaultToolkit(); if (tk instanceof SunToolkit) { Component originalSource = AWTAccessor.getKeyEventAccessor() .getOriginalSource(ev); skip = SunToolkit.getContainingWindow(originalSource) != winAncestor || ev.getWhen() <= ((SunToolkit) tk).getWindowDeactivationTime(winAncestor); } if (menu != null && !skip) { MenuElement[] path = new MenuElement[2]; path[0] = mbar; path[1] = menu; msm.setSelectedPath(path); } else if(!WindowsLookAndFeel.isMnemonicHidden()) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } else { if((msm.getSelectedPath())[0] instanceof ComboPopup) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } }
Example 14
Source File: WindowsRootPaneUI.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
void altReleased(KeyEvent ev) { if (menuCanceledOnPress) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); return; } MenuSelectionManager msm = MenuSelectionManager.defaultManager(); if (msm.getSelectedPath().length == 0) { // if no menu is active, we try activating the menubar JMenuBar mbar = root != null ? root.getJMenuBar() : null; if(mbar == null && winAncestor instanceof JFrame) { mbar = ((JFrame)winAncestor).getJMenuBar(); } JMenu menu = mbar != null ? mbar.getMenu(0) : null; // It might happen that the altRelease event is processed // with a reasonable delay since it has been generated. // Here we check the last deactivation time of the containing // window. If this time appears to be greater than the altRelease // event time the event is skipped to avoid unexpected menu // activation. See 7121442. // Also we must ensure that original source of key event belongs // to the same window object as winAncestor. See 8001633. boolean skip = false; Toolkit tk = Toolkit.getDefaultToolkit(); if (tk instanceof SunToolkit) { Component originalSource = AWTAccessor.getKeyEventAccessor() .getOriginalSource(ev); skip = SunToolkit.getContainingWindow(originalSource) != winAncestor || ev.getWhen() <= ((SunToolkit) tk).getWindowDeactivationTime(winAncestor); } if (menu != null && !skip) { MenuElement[] path = new MenuElement[2]; path[0] = mbar; path[1] = menu; msm.setSelectedPath(path); } else if(!WindowsLookAndFeel.isMnemonicHidden()) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } else { if((msm.getSelectedPath())[0] instanceof ComboPopup) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } }
Example 15
Source File: WindowsRootPaneUI.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
void altReleased(KeyEvent ev) { if (menuCanceledOnPress) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); return; } MenuSelectionManager msm = MenuSelectionManager.defaultManager(); if (msm.getSelectedPath().length == 0) { // if no menu is active, we try activating the menubar JMenuBar mbar = root != null ? root.getJMenuBar() : null; if(mbar == null && winAncestor instanceof JFrame) { mbar = ((JFrame)winAncestor).getJMenuBar(); } JMenu menu = mbar != null ? mbar.getMenu(0) : null; // It might happen that the altRelease event is processed // with a reasonable delay since it has been generated. // Here we check the last deactivation time of the containing // window. If this time appears to be greater than the altRelease // event time the event is skipped to avoid unexpected menu // activation. See 7121442. // Also we must ensure that original source of key event belongs // to the same window object as winAncestor. See 8001633. boolean skip = false; Toolkit tk = Toolkit.getDefaultToolkit(); if (tk instanceof SunToolkit) { Component originalSource = AWTAccessor.getKeyEventAccessor() .getOriginalSource(ev); skip = SunToolkit.getContainingWindow(originalSource) != winAncestor || ev.getWhen() <= ((SunToolkit) tk).getWindowDeactivationTime(winAncestor); } if (menu != null && !skip) { MenuElement[] path = new MenuElement[2]; path[0] = mbar; path[1] = menu; msm.setSelectedPath(path); } else if(!WindowsLookAndFeel.isMnemonicHidden()) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } else { if((msm.getSelectedPath())[0] instanceof ComboPopup) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } }
Example 16
Source File: WindowsRootPaneUI.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
void altReleased(KeyEvent ev) { if (menuCanceledOnPress) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); return; } MenuSelectionManager msm = MenuSelectionManager.defaultManager(); if (msm.getSelectedPath().length == 0) { // if no menu is active, we try activating the menubar JMenuBar mbar = root != null ? root.getJMenuBar() : null; if(mbar == null && winAncestor instanceof JFrame) { mbar = ((JFrame)winAncestor).getJMenuBar(); } JMenu menu = mbar != null ? mbar.getMenu(0) : null; // It might happen that the altRelease event is processed // with a reasonable delay since it has been generated. // Here we check the last deactivation time of the containing // window. If this time appears to be greater than the altRelease // event time the event is skipped to avoid unexpected menu // activation. See 7121442. // Also we must ensure that original source of key event belongs // to the same window object as winAncestor. See 8001633. boolean skip = false; Toolkit tk = Toolkit.getDefaultToolkit(); if (tk instanceof SunToolkit) { Component originalSource = AWTAccessor.getKeyEventAccessor() .getOriginalSource(ev); skip = SunToolkit.getContainingWindow(originalSource) != winAncestor || ev.getWhen() <= ((SunToolkit) tk).getWindowDeactivationTime(winAncestor); } if (menu != null && !skip) { MenuElement[] path = new MenuElement[2]; path[0] = mbar; path[1] = menu; msm.setSelectedPath(path); } else if(!WindowsLookAndFeel.isMnemonicHidden()) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } else { if((msm.getSelectedPath())[0] instanceof ComboPopup) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } }
Example 17
Source File: WindowsRootPaneUI.java From JDKSourceCode1.8 with MIT License | 4 votes |
void altReleased(KeyEvent ev) { if (menuCanceledOnPress) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); return; } MenuSelectionManager msm = MenuSelectionManager.defaultManager(); if (msm.getSelectedPath().length == 0) { // if no menu is active, we try activating the menubar JMenuBar mbar = root != null ? root.getJMenuBar() : null; if(mbar == null && winAncestor instanceof JFrame) { mbar = ((JFrame)winAncestor).getJMenuBar(); } JMenu menu = mbar != null ? mbar.getMenu(0) : null; // It might happen that the altRelease event is processed // with a reasonable delay since it has been generated. // Here we check the last deactivation time of the containing // window. If this time appears to be greater than the altRelease // event time the event is skipped to avoid unexpected menu // activation. See 7121442. // Also we must ensure that original source of key event belongs // to the same window object as winAncestor. See 8001633. boolean skip = false; Toolkit tk = Toolkit.getDefaultToolkit(); if (tk instanceof SunToolkit) { Component originalSource = AWTAccessor.getKeyEventAccessor() .getOriginalSource(ev); skip = SunToolkit.getContainingWindow(originalSource) != winAncestor || ev.getWhen() <= ((SunToolkit) tk).getWindowDeactivationTime(winAncestor); } if (menu != null && !skip) { MenuElement[] path = new MenuElement[2]; path[0] = mbar; path[1] = menu; msm.setSelectedPath(path); } else if(!WindowsLookAndFeel.isMnemonicHidden()) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } else { if((msm.getSelectedPath())[0] instanceof ComboPopup) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } }
Example 18
Source File: WindowsRootPaneUI.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
void altReleased(KeyEvent ev) { if (menuCanceledOnPress) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); return; } MenuSelectionManager msm = MenuSelectionManager.defaultManager(); if (msm.getSelectedPath().length == 0) { // if no menu is active, we try activating the menubar JMenuBar mbar = root != null ? root.getJMenuBar() : null; if(mbar == null && winAncestor instanceof JFrame) { mbar = ((JFrame)winAncestor).getJMenuBar(); } JMenu menu = mbar != null ? mbar.getMenu(0) : null; // It might happen that the altRelease event is processed // with a reasonable delay since it has been generated. // Here we check the last deactivation time of the containing // window. If this time appears to be greater than the altRelease // event time the event is skipped to avoid unexpected menu // activation. See 7121442. // Also we must ensure that original source of key event belongs // to the same window object as winAncestor. See 8001633. boolean skip = false; Toolkit tk = Toolkit.getDefaultToolkit(); if (tk instanceof SunToolkit) { Component originalSource = AWTAccessor.getKeyEventAccessor() .getOriginalSource(ev); skip = SunToolkit.getContainingWindow(originalSource) != winAncestor || ev.getWhen() <= ((SunToolkit) tk).getWindowDeactivationTime(winAncestor); } if (menu != null && !skip) { MenuElement[] path = new MenuElement[2]; path[0] = mbar; path[1] = menu; msm.setSelectedPath(path); } else if(!WindowsLookAndFeel.isMnemonicHidden()) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } else { if((msm.getSelectedPath())[0] instanceof ComboPopup) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } }
Example 19
Source File: WindowsRootPaneUI.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
void altReleased(KeyEvent ev) { if (menuCanceledOnPress) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); return; } MenuSelectionManager msm = MenuSelectionManager.defaultManager(); if (msm.getSelectedPath().length == 0) { // if no menu is active, we try activating the menubar JMenuBar mbar = root != null ? root.getJMenuBar() : null; if(mbar == null && winAncestor instanceof JFrame) { mbar = ((JFrame)winAncestor).getJMenuBar(); } JMenu menu = mbar != null ? mbar.getMenu(0) : null; // It might happen that the altRelease event is processed // with a reasonable delay since it has been generated. // Here we check the last deactivation time of the containing // window. If this time appears to be greater than the altRelease // event time the event is skipped to avoid unexpected menu // activation. See 7121442. // Also we must ensure that original source of key event belongs // to the same window object as winAncestor. See 8001633. boolean skip = false; Toolkit tk = Toolkit.getDefaultToolkit(); if (tk instanceof SunToolkit) { Component originalSource = AWTAccessor.getKeyEventAccessor() .getOriginalSource(ev); skip = SunToolkit.getContainingWindow(originalSource) != winAncestor || ev.getWhen() <= ((SunToolkit) tk).getWindowDeactivationTime(winAncestor); } if (menu != null && !skip) { MenuElement[] path = new MenuElement[2]; path[0] = mbar; path[1] = menu; msm.setSelectedPath(path); } else if(!WindowsLookAndFeel.isMnemonicHidden()) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } else { if((msm.getSelectedPath())[0] instanceof ComboPopup) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } }
Example 20
Source File: WindowsRootPaneUI.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
void altReleased(KeyEvent ev) { if (menuCanceledOnPress) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); return; } MenuSelectionManager msm = MenuSelectionManager.defaultManager(); if (msm.getSelectedPath().length == 0) { // if no menu is active, we try activating the menubar JMenuBar mbar = root != null ? root.getJMenuBar() : null; if(mbar == null && winAncestor instanceof JFrame) { mbar = ((JFrame)winAncestor).getJMenuBar(); } JMenu menu = mbar != null ? mbar.getMenu(0) : null; // It might happen that the altRelease event is processed // with a reasonable delay since it has been generated. // Here we check the last deactivation time of the containing // window. If this time appears to be greater than the altRelease // event time the event is skipped to avoid unexpected menu // activation. See 7121442. // Also we must ensure that original source of key event belongs // to the same window object as winAncestor. See 8001633. boolean skip = false; Toolkit tk = Toolkit.getDefaultToolkit(); if (tk instanceof SunToolkit) { Component originalSource = AWTAccessor.getKeyEventAccessor() .getOriginalSource(ev); skip = SunToolkit.getContainingWindow(originalSource) != winAncestor || ev.getWhen() <= ((SunToolkit) tk).getWindowDeactivationTime(winAncestor); } if (menu != null && !skip) { MenuElement[] path = new MenuElement[2]; path[0] = mbar; path[1] = menu; msm.setSelectedPath(path); } else if(!WindowsLookAndFeel.isMnemonicHidden()) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } else { if((msm.getSelectedPath())[0] instanceof ComboPopup) { WindowsLookAndFeel.setMnemonicHidden(true); WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor); } } }