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

Print this page




 139         public void actionPerformed(ActionEvent e) {
 140             JMenuBar menuBar = (JMenuBar)e.getSource();
 141             JMenu menu = menuBar.getMenu(0);
 142             if (menu != null) {
 143                 MenuSelectionManager msm =
 144                     MenuSelectionManager.defaultManager();
 145                 MenuElement path[] = new MenuElement[2];
 146                 path[0] = (MenuElement)menuBar;
 147                 path[1] = (MenuElement)menu;
 148                 msm.setSelectedPath(path);
 149 
 150                 // show mnemonics
 151                 WindowsLookAndFeel.setMnemonicHidden(false);
 152                 WindowsLookAndFeel.repaintRootPane(menuBar);
 153             }
 154         }
 155     }
 156 
 157     @Override
 158     public void paint(Graphics g, JComponent c) {
 159         if (WindowsMenuItemUI.isVistaPainting()) {
 160             XPStyle xp = XPStyle.getXP();

 161             Skin skin;
 162             skin = xp.getSkin(c, Part.MP_BARBACKGROUND);
 163             int width = c.getWidth();
 164             int height = c.getHeight();
 165             State state =  isActive(c) ? State.ACTIVE : State.INACTIVE;
 166             skin.paintSkin(g, 0, 0, width, height, state);
 167         } else {
 168             super.paint(g, c);
 169         }
 170     }
 171 
 172     /**
 173      * Checks if component belongs to an active window.
 174      * @param c component to check
 175      * @return true if component belongs to an active window
 176      */
 177     static boolean isActive(JComponent c) {
 178         JRootPane rootPane = c.getRootPane();
 179         if (rootPane != null) {
 180             Component component = rootPane.getParent();


 139         public void actionPerformed(ActionEvent e) {
 140             JMenuBar menuBar = (JMenuBar)e.getSource();
 141             JMenu menu = menuBar.getMenu(0);
 142             if (menu != null) {
 143                 MenuSelectionManager msm =
 144                     MenuSelectionManager.defaultManager();
 145                 MenuElement path[] = new MenuElement[2];
 146                 path[0] = (MenuElement)menuBar;
 147                 path[1] = (MenuElement)menu;
 148                 msm.setSelectedPath(path);
 149 
 150                 // show mnemonics
 151                 WindowsLookAndFeel.setMnemonicHidden(false);
 152                 WindowsLookAndFeel.repaintRootPane(menuBar);
 153             }
 154         }
 155     }
 156 
 157     @Override
 158     public void paint(Graphics g, JComponent c) {

 159         XPStyle xp = XPStyle.getXP();
 160         if (WindowsMenuItemUI.isVistaPainting(xp)) {
 161             Skin skin;
 162             skin = xp.getSkin(c, Part.MP_BARBACKGROUND);
 163             int width = c.getWidth();
 164             int height = c.getHeight();
 165             State state =  isActive(c) ? State.ACTIVE : State.INACTIVE;
 166             skin.paintSkin(g, 0, 0, width, height, state);
 167         } else {
 168             super.paint(g, c);
 169         }
 170     }
 171 
 172     /**
 173      * Checks if component belongs to an active window.
 174      * @param c component to check
 175      * @return true if component belongs to an active window
 176      */
 177     static boolean isActive(JComponent c) {
 178         JRootPane rootPane = c.getRootPane();
 179         if (rootPane != null) {
 180             Component component = rootPane.getParent();