src/share/classes/com/sun/java/swing/plaf/windows/WindowsIconFactory.java
Print this page
@@ -621,12 +621,12 @@
} // End class MenuItemArrowIcon
@SuppressWarnings("serial") // Same-version serialization only
private static class MenuArrowIcon implements Icon, UIResource, Serializable {
public void paintIcon(Component c, Graphics g, int x, int y) {
- if (WindowsMenuItemUI.isVistaPainting()) {
XPStyle xp = XPStyle.getXP();
+ if (xp != null && WindowsMenuItemUI.isVistaPainting()) {
State state = State.NORMAL;
if (c instanceof JMenuItem) {
state = ((JMenuItem) c).getModel().isEnabled()
? State.NORMAL : State.DISABLED;
}
@@ -655,20 +655,22 @@
}
g.translate(-x,-y);
}
}
public int getIconWidth() {
- if (WindowsMenuItemUI.isVistaPainting()) {
- Skin skin = XPStyle.getXP().getSkin(null, Part.MP_POPUPSUBMENU);
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null && WindowsMenuItemUI.isVistaPainting()) {
+ Skin skin = xp.getSkin(null, Part.MP_POPUPSUBMENU);
return skin.getWidth();
} else {
return 4;
}
}
public int getIconHeight() {
- if (WindowsMenuItemUI.isVistaPainting()) {
- Skin skin = XPStyle.getXP().getSkin(null, Part.MP_POPUPSUBMENU);
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null && WindowsMenuItemUI.isVistaPainting()) {
+ Skin skin = xp.getSkin(null, Part.MP_POPUPSUBMENU);
return skin.getHeight();
} else {
return 8;
}
}
@@ -690,11 +692,12 @@
public Icon getIcon(String type) {
return new VistaMenuItemCheckIcon(type);
}
static int getIconWidth() {
- return XPStyle.getXP().getSkin(null, Part.MP_POPUPCHECK).getWidth()
+ XPStyle xp = XPStyle.getXP();
+ return ((xp != null) ? xp.getSkin(null, Part.MP_POPUPCHECK).getWidth() : 16)
+ 2 * OFFSET;
}
private static Class<? extends JMenuItem> getType(Component c) {
Class<? extends JMenuItem> rv = null;
@@ -754,16 +757,21 @@
return lafIcon.getIconHeight();
}
Icon icon = getIcon();
int height = 0;
if (icon != null) {
- height = icon.getIconHeight() + 2 * OFFSET;
+ height = icon.getIconHeight();
+ } else {
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ Skin skin = xp.getSkin(null, Part.MP_POPUPCHECK);
+ height = skin.getHeight();
} else {
- Skin skin =
- XPStyle.getXP().getSkin(null, Part.MP_POPUPCHECK);
- height = skin.getHeight() + 2 * OFFSET;
+ height = 16;
}
+ }
+ height += 2 * OFFSET;
return height;
}
public int getIconWidth() {
Icon lafIcon = getLaFIcon();
@@ -807,21 +815,23 @@
state =
(type == JRadioButtonMenuItem.class)
? State.BULLETDISABLED
: State.CHECKMARKDISABLED;
}
- Skin skin;
XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ Skin skin;
skin = xp.getSkin(c, backgroundPart);
skin.paintSkin(g, x, y,
getIconWidth(), getIconHeight(), backgroundState);
if (icon == null) {
skin = xp.getSkin(c, part);
skin.paintSkin(g, x + OFFSET, y + OFFSET, state);
}
}
}
+ }
if (icon != null) {
icon.paintIcon(c, g, x + OFFSET, y + OFFSET);
}
}
private static WindowsMenuItemUIAccessor getAccessor(