src/share/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1997, 2013, 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
@@ -35,10 +35,11 @@
import java.awt.*;
import static com.sun.java.swing.plaf.windows.TMSchema.Part;
import static com.sun.java.swing.plaf.windows.TMSchema.State;
import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
+
import sun.swing.DefaultLookup;
import sun.swing.StringUIClientPropertyKey;
/**
@@ -229,10 +230,13 @@
return state;
}
private void paintXPComboBoxBackground(Graphics g, JComponent c) {
XPStyle xp = XPStyle.getXP();
+ if (xp == null) {
+ return;
+ }
State state = getXPComboBoxState(c);
Skin skin = null;
if (! comboBox.isEditable()
&& xp.isSkinDefined(c, Part.CP_READONLY)) {
skin = xp.getSkin(c, Part.CP_READONLY);
@@ -398,22 +402,23 @@
* the popup portion of the combo box.
*
* @return a button which represents the popup control
*/
protected JButton createArrowButton() {
- if (XPStyle.getXP() != null) {
- return new XPComboBoxButton();
+ XPStyle xp = XPStyle.getXP();
+ if (xp != null) {
+ return new XPComboBoxButton(xp);
} else {
return super.createArrowButton();
}
}
@SuppressWarnings("serial") // Superclass is not serializable across versions
private class XPComboBoxButton extends XPStyle.GlyphButton {
- public XPComboBoxButton() {
+ public XPComboBoxButton(XPStyle xp) {
super(null,
- (! XPStyle.getXP().isSkinDefined(comboBox, Part.CP_DROPDOWNBUTTONRIGHT))
+ (! xp.isSkinDefined(comboBox, Part.CP_DROPDOWNBUTTONRIGHT))
? Part.CP_DROPDOWNBUTTON
: (comboBox.getComponentOrientation() == ComponentOrientation.RIGHT_TO_LEFT)
? Part.CP_DROPDOWNBUTTONLEFT
: Part.CP_DROPDOWNBUTTONRIGHT
);
@@ -422,13 +427,14 @@
@Override
protected State getState() {
State rv;
rv = super.getState();
+ XPStyle xp = XPStyle.getXP();
if (rv != State.DISABLED
&& comboBox != null && ! comboBox.isEditable()
- && XPStyle.getXP().isSkinDefined(comboBox,
+ && xp != null && xp.isSkinDefined(comboBox,
Part.CP_DROPDOWNBUTTONRIGHT)) {
/*
* for non editable ComboBoxes Vista seems to have the
* same glyph for all non DISABLED states
*/