8203281: [Windows] JComboBox change in ui when editor.setBorder() is called
authorpsadhukhan
Thu, 04 Oct 2018 14:56:03 +0530
changeset 52245 651c3558ae2b
parent 52244 8716dd44bc37
child 52246 f49c340e3f39
8203281: [Windows] JComboBox change in ui when editor.setBorder() is called Reviewed-by: psadhukhan Contributed-by: mraz.martin.dev@gmail.com
src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java
src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java
--- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java	Thu Oct 04 14:17:59 2018 +0530
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsComboBoxUI.java	Thu Oct 04 14:56:03 2018 +0530
@@ -154,7 +154,7 @@
             comboBox.addMouseListener(rolloverListener);
             arrowButton.addMouseListener(rolloverListener);
             // set empty border as default to see vista animated border
-            comboBox.setBorder(new EmptyBorder(0,0,0,0));
+            comboBox.setBorder(new EmptyBorder(1,1,1,1));
         }
     }
 
@@ -366,12 +366,20 @@
                 if (XPStyle.getXP() != null && arrowButton != null) {
                     Dimension d = parent.getSize();
                     Insets insets = getInsets();
-                    int buttonWidth = arrowButton.getPreferredSize().width;
-                    arrowButton.setBounds(WindowsGraphicsUtils.isLeftToRight((JComboBox)parent)
-                                          ? (d.width - insets.right - buttonWidth)
-                                          : insets.left,
-                                          insets.top,
-                                          buttonWidth, d.height - insets.top - insets.bottom);
+
+                    int borderInsetsCorrection = 0;
+                    if (((JComboBox)parent).getBorder() instanceof EmptyBorder) {
+                        borderInsetsCorrection = 1;
+                    }
+                    arrowButton.setBounds(
+                        WindowsGraphicsUtils.isLeftToRight((JComboBox)parent)
+                            ? (d.width - (insets.right - borderInsetsCorrection)
+                                - arrowButton.getPreferredSize().width)
+                            : insets.left - borderInsetsCorrection,
+                            insets.top - borderInsetsCorrection,
+                            arrowButton.getPreferredSize().width,
+                            d.height - (insets.top - borderInsetsCorrection) -
+                                    (insets.bottom - borderInsetsCorrection));
                 }
             }
         };
--- a/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java	Thu Oct 04 14:17:59 2018 +0530
+++ b/src/java.desktop/windows/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java	Thu Oct 04 14:56:03 2018 +0530
@@ -672,8 +672,8 @@
             "ComboBox.buttonHighlight", ControlHighlightColor,
             "ComboBox.selectionBackground", SelectionBackgroundColor,
             "ComboBox.selectionForeground", SelectionTextColor,
-            "ComboBox.editorBorder", new XPValue(new EmptyBorder(1,4,1,1),
-                                                 new EmptyBorder(1,4,1,4)),
+            "ComboBox.editorBorder", new XPValue(new EmptyBorder(1,3,1,1),
+                                                 new EmptyBorder(1,3,1,4)),
             "ComboBox.disabledBackground",
                         new XPColorValue(Part.CP_COMBOBOX, State.DISABLED,
                         Prop.FILLCOLOR, DisabledTextBackground),