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

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -106,21 +106,21 @@
         super.paintBackground(g, menuItem, bgColor);
     }
 
     static void paintBackground(WindowsMenuItemUIAccessor menuItemUI,
             Graphics g, JMenuItem menuItem, Color bgColor) {
-        assert isVistaPainting();
-        if (isVistaPainting()) {
+        XPStyle xp = XPStyle.getXP();
+        assert isVistaPainting(xp);
+        if (isVistaPainting(xp)) {
             int menuWidth = menuItem.getWidth();
             int menuHeight = menuItem.getHeight();
             if (menuItem.isOpaque()) {
                 Color oldColor = g.getColor();
                 g.setColor(menuItem.getBackground());
                 g.fillRect(0,0, menuWidth, menuHeight);
                 g.setColor(oldColor);
             }
-            XPStyle xp = XPStyle.getXP();
             Part part = menuItemUI.getPart(menuItem);
             Skin skin = xp.getSkin(menuItem, part);
             skin.paintSkin(g, 0 , 0,
                 menuWidth,
                 menuHeight,

@@ -168,10 +168,13 @@
     /*
      * TODO idk can we use XPStyle.isVista?
      * is it possible that in some theme some Vista parts are not defined while
      * others are?
      */
-    static boolean isVistaPainting() {
-        XPStyle xp = XPStyle.getXP();
+    static boolean isVistaPainting(final XPStyle xp) {
         return xp != null && xp.isSkinDefined(null, Part.MP_POPUPITEM);
     }
+
+    static boolean isVistaPainting() {
+        return isVistaPainting(XPStyle.getXP());
+    }
 }