src/share/classes/com/sun/java/swing/plaf/windows/WindowsRootPaneUI.java

Print this page




  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.java.swing.plaf.windows;
  27 
  28 import java.awt.Component;
  29 import java.awt.Container;
  30 import java.awt.Event;
  31 import java.awt.KeyEventPostProcessor;
  32 import java.awt.Window;


  33 
  34 import java.awt.event.ActionEvent;
  35 import java.awt.event.KeyEvent;
  36 
  37 import javax.swing.AbstractAction;
  38 import javax.swing.ActionMap;
  39 import javax.swing.InputMap;
  40 import javax.swing.KeyStroke;
  41 import javax.swing.JComponent;
  42 import javax.swing.JLabel;
  43 import javax.swing.JRootPane;
  44 import javax.swing.SwingUtilities;
  45 import javax.swing.UIManager;
  46 import javax.swing.AbstractButton;
  47 import javax.swing.JFrame;
  48 import javax.swing.JMenu;
  49 import javax.swing.JMenuBar;
  50 import javax.swing.MenuElement;
  51 import javax.swing.MenuSelectionManager;
  52 


 108         }
 109 
 110         void altReleased(KeyEvent ev) {
 111             if (menuCanceledOnPress) {
 112                 WindowsLookAndFeel.setMnemonicHidden(true);
 113                 WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
 114                 return;
 115             }
 116 
 117             MenuSelectionManager msm =
 118                 MenuSelectionManager.defaultManager();
 119             if (msm.getSelectedPath().length == 0) {
 120                 // if no menu is active, we try activating the menubar
 121 
 122                 JMenuBar mbar = root != null ? root.getJMenuBar() : null;
 123                 if(mbar == null && winAncestor instanceof JFrame) {
 124                     mbar = ((JFrame)winAncestor).getJMenuBar();
 125                 }
 126                 JMenu menu = mbar != null ? mbar.getMenu(0) : null;
 127 
 128                 if (menu != null) {








 129                     MenuElement[] path = new MenuElement[2];
 130                     path[0] = mbar;
 131                     path[1] = menu;
 132                     msm.setSelectedPath(path);
 133                 } else if(!WindowsLookAndFeel.isMnemonicHidden()) {
 134                     WindowsLookAndFeel.setMnemonicHidden(true);
 135                     WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
 136                 }
 137             } else {
 138                 if((msm.getSelectedPath())[0] instanceof ComboPopup) {
 139                     WindowsLookAndFeel.setMnemonicHidden(true);
 140                     WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
 141                 }
 142             }
 143 
 144         }
 145 
 146         public boolean postProcessKeyEvent(KeyEvent ev) {
 147             if(ev.isConsumed()) {
 148                 // do not manage consumed event




  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.java.swing.plaf.windows;
  27 
  28 import java.awt.Component;
  29 import java.awt.Container;
  30 import java.awt.Event;
  31 import java.awt.KeyEventPostProcessor;
  32 import java.awt.Window;
  33 import java.awt.Toolkit;
  34 import sun.awt.SunToolkit;
  35 
  36 import java.awt.event.ActionEvent;
  37 import java.awt.event.KeyEvent;
  38 
  39 import javax.swing.AbstractAction;
  40 import javax.swing.ActionMap;
  41 import javax.swing.InputMap;
  42 import javax.swing.KeyStroke;
  43 import javax.swing.JComponent;
  44 import javax.swing.JLabel;
  45 import javax.swing.JRootPane;
  46 import javax.swing.SwingUtilities;
  47 import javax.swing.UIManager;
  48 import javax.swing.AbstractButton;
  49 import javax.swing.JFrame;
  50 import javax.swing.JMenu;
  51 import javax.swing.JMenuBar;
  52 import javax.swing.MenuElement;
  53 import javax.swing.MenuSelectionManager;
  54 


 110         }
 111 
 112         void altReleased(KeyEvent ev) {
 113             if (menuCanceledOnPress) {
 114                 WindowsLookAndFeel.setMnemonicHidden(true);
 115                 WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
 116                 return;
 117             }
 118 
 119             MenuSelectionManager msm =
 120                 MenuSelectionManager.defaultManager();
 121             if (msm.getSelectedPath().length == 0) {
 122                 // if no menu is active, we try activating the menubar
 123 
 124                 JMenuBar mbar = root != null ? root.getJMenuBar() : null;
 125                 if(mbar == null && winAncestor instanceof JFrame) {
 126                     mbar = ((JFrame)winAncestor).getJMenuBar();
 127                 }
 128                 JMenu menu = mbar != null ? mbar.getMenu(0) : null;
 129 
 130                 // Skip menu activation if the KeyEvent originated before
 131                 // the latest window deactivation.
 132                 boolean skip = false;
 133                 Toolkit tk = Toolkit.getDefaultToolkit();
 134                 if (tk instanceof SunToolkit) {
 135                     skip = ev.getWhen() <= ((SunToolkit)tk).getDeactivationTime(winAncestor);
 136                 }
 137 
 138                 if (menu != null && !skip) {
 139                     MenuElement[] path = new MenuElement[2];
 140                     path[0] = mbar;
 141                     path[1] = menu;
 142                     msm.setSelectedPath(path);
 143                 } else if(!WindowsLookAndFeel.isMnemonicHidden()) {
 144                     WindowsLookAndFeel.setMnemonicHidden(true);
 145                     WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
 146                 }
 147             } else {
 148                 if((msm.getSelectedPath())[0] instanceof ComboPopup) {
 149                     WindowsLookAndFeel.setMnemonicHidden(true);
 150                     WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
 151                 }
 152             }
 153 
 154         }
 155 
 156         public boolean postProcessKeyEvent(KeyEvent ev) {
 157             if(ev.isConsumed()) {
 158                 // do not manage consumed event