changeset 3461:72f1247e9ff5

6532833: PIT: Metal LAF - The right side border is not shown for the Spinner after the removing the buttons Reviewed-by: alexp
author rupashka
date Mon, 27 Dec 2010 17:41:33 +0300
parents c06d4327c0f2
children 2c3c88a389b0
files src/share/classes/javax/swing/plaf/basic/BasicSpinnerUI.java test/javax/swing/JSpinner/6532833/bug6532833.java
diffstat 2 files changed, 88 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/javax/swing/plaf/basic/BasicSpinnerUI.java	Mon Dec 27 15:28:08 2010 +0300
+++ b/src/share/classes/javax/swing/plaf/basic/BasicSpinnerUI.java	Mon Dec 27 17:41:33 2010 +0300
@@ -908,6 +908,14 @@
             int height = parent.getHeight();
 
             Insets insets = parent.getInsets();
+
+            if (nextButton == null && previousButton == null) {
+                setBounds(editor, insets.left,  insets.top, width - insets.left - insets.right,
+                        height - insets.top - insets.bottom);
+
+                return;
+            }
+
             Dimension nextD = preferredSize(nextButton);
             Dimension previousD = preferredSize(previousButton);
             int buttonsWidth = Math.max(nextD.width, previousD.width);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/javax/swing/JSpinner/6532833/bug6532833.java	Mon Dec 27 17:41:33 2010 +0300
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2010, 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.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/* @test
+   @bug 6532833
+   @summary PIT: Metal LAF - The right side border is not shown for the Spinner after the removing the buttons
+   @author Pavel Porvatov
+*/
+
+import javax.swing.*;
+import java.awt.*;
+
+public class bug6532833 {
+    public static void main(String[] args) throws Exception {
+        SwingUtilities.invokeAndWait(new Runnable() {
+            public void run() {
+                JSpinner[] spinners = new JSpinner[2];
+
+                for (int i = 0; i < spinners.length; i++) {
+                    JSpinner spinner = new JSpinner();
+
+                    spinner.setValue(2010);
+
+                    Component arrowUp = spinner.getComponent(0);
+                    Component arrowDown = spinner.getComponent(1);
+
+                    LayoutManager layout = spinner.getLayout();
+
+                    layout.removeLayoutComponent(arrowUp);
+                    layout.removeLayoutComponent(arrowDown);
+
+                    if (i == 1) {
+                        spinner.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
+                    }
+
+                    spinners[i] = spinner;
+                }
+
+                // Do layout of spinners components
+                JFrame frame = new JFrame();
+
+                for (JSpinner spinner : spinners) {
+                    frame.getContentPane().add(spinner);
+                }
+
+                frame.pack();
+
+                for (JSpinner spinner : spinners) {
+                    Insets insets = spinner.getInsets();
+
+                    if (spinner.getWidth() != insets.left + insets.right + spinner.getEditor().getWidth()) {
+                        throw new RuntimeException("Spinner editor width is invalid");
+                    }
+                }
+
+                frame.dispose();
+            }
+        });
+    }
+}