8075907: The regression-swing case failed as the rollover icons is not correctly shown with the special options"-client -Dswing.defaultlaf=javax.swing.plaf.nimbus.NimbusLookAndFeel"
authorssadetsky
Thu, 24 Mar 2016 20:10:52 +0300
changeset 36910 b9abecc8eaec
parent 36909 0050cca057b1
child 36911 81adb67ad4ba
8075907: The regression-swing case failed as the rollover icons is not correctly shown with the special options"-client -Dswing.defaultlaf=javax.swing.plaf.nimbus.NimbusLookAndFeel" Reviewed-by: alexsch
jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java	Thu Mar 24 20:03:38 2016 +0300
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthButtonUI.java	Thu Mar 24 20:10:52 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2016, 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
@@ -357,7 +357,7 @@
      * This method will return the icon that should be used for a button.  We
      * only want to use the synth icon defined by the style if the specific
      * icon has not been defined for the button state and the backup icon is a
-     * UIResource (we set it, not the developer).
+     * UIResource (we set it, not the developer) or {@code null}.
      *
      * @param b button
      * @param specificIcon icon returned from the button for the specific state
@@ -368,7 +368,7 @@
             int state) {
         Icon icon = specificIcon;
         if (icon == null) {
-            if (defaultIcon instanceof UIResource) {
+            if (defaultIcon == null || defaultIcon instanceof UIResource) {
                 icon = getSynthIcon(b, state);
                 if (icon == null) {
                     icon = defaultIcon;
@@ -398,11 +398,16 @@
 
     private Icon getRolloverIcon(AbstractButton b, Icon defaultIcon) {
         ButtonModel model = b.getModel();
-        Icon icon;
+        Icon icon = null;
         if (model.isSelected()) {
-            icon = getIcon(b, b.getRolloverSelectedIcon(), defaultIcon,
+            icon = getIcon(b, b.getRolloverSelectedIcon(), null,
                     SynthConstants.MOUSE_OVER | SynthConstants.SELECTED);
-        } else {
+            if (icon == null) {
+                icon = getIcon(b, b.getSelectedIcon(), null,
+                        SynthConstants.SELECTED);
+            }
+        }
+        if (icon == null) {
             icon = getIcon(b, b.getRolloverIcon(), defaultIcon,
                     SynthConstants.MOUSE_OVER);
         }
@@ -416,11 +421,16 @@
 
     private Icon getSynthDisabledIcon(AbstractButton b, Icon defaultIcon) {
         ButtonModel model = b.getModel();
-        Icon icon;
+        Icon icon = null;
         if (model.isSelected()) {
-            icon = getIcon(b, b.getDisabledSelectedIcon(), defaultIcon,
+            icon = getIcon(b, b.getDisabledSelectedIcon(), null,
                     SynthConstants.DISABLED | SynthConstants.SELECTED);
-        } else {
+            if (icon == null) {
+                icon = getIcon(b, b.getSelectedIcon(), null,
+                        SynthConstants.SELECTED);
+            }
+        }
+        if (icon == null) {
             icon = getIcon(b, b.getDisabledIcon(), defaultIcon,
                     SynthConstants.DISABLED);
         }