--- old/src/share/classes/com/sun/java/swing/plaf/windows/XPStyle.java 2014-07-02 16:29:35.024772400 +0400 +++ new/src/share/classes/com/sun/java/swing/plaf/windows/XPStyle.java 2014-07-02 16:29:34.502262700 +0400 @@ -115,7 +115,7 @@ } } } - return xp; + return ThemeReader.isXPStyleEnabled() ? xp : null; } static boolean isVista() { @@ -180,9 +180,10 @@ * should probably be cached there instead of here. */ Dimension getDimension(Component c, Part part, State state, Prop prop) { - return ThemeReader.getPosition(part.getControlName(c), part.getValue(), - State.getValue(part, state), - prop.getValue()); + Dimension d = ThemeReader.getPosition(part.getControlName(c), part.getValue(), + State.getValue(part, state), + prop.getValue()); + return (d != null) ? d : new Dimension(); } /** Get a named Point (e.g. a location or an offset) value @@ -199,11 +200,7 @@ Dimension d = ThemeReader.getPosition(part.getControlName(c), part.getValue(), State.getValue(part, state), prop.getValue()); - if (d != null) { - return new Point(d.width, d.height); - } else { - return null; - } + return (d != null) ? new Point(d.width, d.height) : new Point(); } /** Get a named Insets value from the current style @@ -217,9 +214,10 @@ * The return value is already cached in those places. */ Insets getMargin(Component c, Part part, State state, Prop prop) { - return ThemeReader.getThemeMargins(part.getControlName(c), part.getValue(), - State.getValue(part, state), - prop.getValue()); + Insets insets = ThemeReader.getThemeMargins(part.getControlName(c), part.getValue(), + State.getValue(part, state), + prop.getValue()); + return (insets != null) ? insets : new Insets(0, 0, 0, 0); } @@ -509,16 +507,17 @@ int boundingWidth = 100; int boundingHeight = 100; - return ThemeReader.getThemeBackgroundContentMargins( + Insets insets = ThemeReader.getThemeBackgroundContentMargins( part.getControlName(null), part.getValue(), 0, boundingWidth, boundingHeight); + return (insets != null) ? insets : new Insets(0, 0, 0, 0); } private int getWidth(State state) { if (size == null) { size = getPartSize(part, state); } - return size.width; + return (size != null) ? size.width : 0; } int getWidth() { @@ -529,7 +528,7 @@ if (size == null) { size = getPartSize(part, state); } - return size.height; + return (size != null) ? size.height : 0; } int getHeight() { @@ -586,6 +585,9 @@ * @param state which state to paint */ void paintSkin(Graphics g, int dx, int dy, int dw, int dh, State state) { + if (XPStyle.getXP() == null) { + return; + } if (ThemeReader.isGetThemeTransitionDurationDefined() && component instanceof JComponent && SwingUtilities.getAncestorOfClass(CellRendererPane.class, @@ -611,6 +613,9 @@ * @param state which state to paint */ void paintSkinRaw(Graphics g, int dx, int dy, int dw, int dh, State state) { + if (XPStyle.getXP() == null) { + return; + } skinPainter.paint(null, g, dx, dy, dw, dh, this, state); } @@ -629,6 +634,9 @@ */ void paintSkin(Graphics g, int dx, int dy, int dw, int dh, State state, boolean borderFill) { + if (XPStyle.getXP() == null) { + return; + } if(borderFill && "borderfill".equals(getTypeEnumName(component, part, state, Prop.BGTYPE))) { return; @@ -684,7 +692,7 @@ public GlyphButton(Component parent, Part part) { XPStyle xp = getXP(); - skin = xp.getSkin(parent, part); + skin = xp != null ? xp.getSkin(parent, part) : null; setBorder(null); setContentAreaFilled(false); setMinimumSize(new Dimension(5, 5)); @@ -709,13 +717,16 @@ } public void paintComponent(Graphics g) { + if (XPStyle.getXP() == null || skin == null) { + return; + } Dimension d = getSize(); skin.paintSkin(g, 0, 0, d.width, d.height, getState()); } public void setPart(Component parent, Part part) { XPStyle xp = getXP(); - skin = xp.getSkin(parent, part); + skin = xp != null ? xp.getSkin(parent, part) : null; revalidate(); repaint(); }