Mercurial > hg > release > icedtea8-forest-3.0 > jdk
changeset 11704:72ab45285f0e jdk8u66-b34
8134828: Scrollbar thumb disappears with Nimbus L&F
Reviewed-by: alexsch, alexp
author | aivanov |
---|---|
date | Thu, 29 Oct 2015 19:37:59 +0300 |
parents | 4e3eb6702ee8 |
children | e169a214f1f0 |
files | src/share/classes/javax/swing/plaf/nimbus/AbstractRegionPainter.java src/share/classes/javax/swing/plaf/nimbus/skin.laf src/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java test/javax/swing/plaf/nimbus/8041642/ScrollBarThumbVisibleTest.java |
diffstat | 4 files changed, 118 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/classes/javax/swing/plaf/nimbus/AbstractRegionPainter.java Fri Nov 13 15:38:50 2015 -0800 +++ b/src/share/classes/javax/swing/plaf/nimbus/AbstractRegionPainter.java Thu Oct 29 19:37:59 2015 +0300 @@ -625,10 +625,6 @@ // check if we can scale to the requested size Dimension canvas = ctx.canvasSize; Insets insets = ctx.stretchingInsets; - if (insets.left + insets.right > w || insets.top + insets.bottom > h) { - return; - } - if (w <= (canvas.width * ctx.maxHorizontalScaleFactor) && h <= (canvas.height * ctx.maxVerticalScaleFactor)) { // get image at canvas size VolatileImage img = getImage(g.getDeviceConfiguration(), c, canvas.width, canvas.height, extendedCacheKeys);
--- a/src/share/classes/javax/swing/plaf/nimbus/skin.laf Fri Nov 13 15:38:50 2015 -0800 +++ b/src/share/classes/javax/swing/plaf/nimbus/skin.laf Thu Oct 29 19:37:59 2015 +0300 @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- - Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 1998, 2015, 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 @@ -16195,6 +16195,10 @@ <dimension width="150" height="19"/> </uiProperty> <uiProperty name="cycleTime" type="INT" value="250"/> + <uiProperty name="minBarSize" type="DIMENSION"> + <dimension width="6" height="6"/> + </uiProperty> + <uiProperty name="glowWidth" type="INT" value="2"/> </uiproperties> </style> <backgroundStates> @@ -16351,7 +16355,7 @@ <canvas> <size width="27" height="19"/> <nextLayerNameIndex>2</nextLayerNameIndex> - <stretchingInsets top="5" bottom="5" left="5" right="5"/> + <stretchingInsets top="3" bottom="3" left="3" right="3"/> <layer name="Layer 1"> <opacity>1.0</opacity> <fillOpacity>1.0</fillOpacity> @@ -16444,7 +16448,7 @@ <canvas> <size width="27" height="19"/> <nextLayerNameIndex>2</nextLayerNameIndex> - <stretchingInsets top="5" bottom="5" left="5" right="5"/> + <stretchingInsets top="3" bottom="3" left="3" right="3"/> <layer name="Layer 1"> <opacity>1.0</opacity> <fillOpacity>1.0</fillOpacity> @@ -16528,7 +16532,7 @@ <canvas> <size width="30" height="13"/> <nextLayerNameIndex>2</nextLayerNameIndex> - <stretchingInsets top="5" bottom="5" left="5" right="5"/> + <stretchingInsets top="3" bottom="3" left="3" right="3"/> <layer name="Layer 1"> <opacity>1.0</opacity> <fillOpacity>1.0</fillOpacity> @@ -16619,7 +16623,7 @@ <canvas> <size width="27" height="19"/> <nextLayerNameIndex>2</nextLayerNameIndex> - <stretchingInsets top="5" bottom="5" left="5" right="5"/> + <stretchingInsets top="3" bottom="3" left="3" right="3"/> <layer name="Layer 1"> <opacity>1.0</opacity> <fillOpacity>1.0</fillOpacity> @@ -16701,7 +16705,7 @@ <canvas> <size width="27" height="19"/> <nextLayerNameIndex>2</nextLayerNameIndex> - <stretchingInsets top="5" bottom="5" left="5" right="5"/> + <stretchingInsets top="3" bottom="3" left="3" right="3"/> <layer name="Layer 1"> <opacity>1.0</opacity> <fillOpacity>1.0</fillOpacity> @@ -16785,7 +16789,7 @@ <canvas> <size width="30" height="13"/> <nextLayerNameIndex>2</nextLayerNameIndex> - <stretchingInsets top="5" bottom="5" left="5" right="5"/> + <stretchingInsets top="3" bottom="3" left="3" right="3"/> <layer name="Layer 1"> <opacity>1.0</opacity> <fillOpacity>1.0</fillOpacity>
--- a/src/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java Fri Nov 13 15:38:50 2015 -0800 +++ b/src/share/classes/javax/swing/plaf/synth/SynthProgressBarUI.java Thu Oct 29 19:37:59 2015 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2015, 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 @@ -49,6 +49,8 @@ private boolean paintOutsideClip; private boolean tileWhenIndeterminate; //whether to tile indeterminate painting private int tileWidth; //the width of each tile + private Dimension minBarSize; // minimal visible bar size + private int glowWidth; // Glow around the bar foreground /** * Creates a new UI object for the given component. @@ -114,6 +116,8 @@ tileWidth *= 0.784; } } + minBarSize = (Dimension)style.get(context, "ProgressBar.minBarSize"); + glowWidth = style.getInt(context, "ProgressBar.glowWidth", 0); context.dispose(); } @@ -258,7 +262,7 @@ if (!SynthLookAndFeel.isLeftToRight(pBar)) { x = pBar.getWidth() - pBarInsets.right - width - - progressPadding; + - progressPadding - glowWidth; } } else { // JProgressBar.VERTICAL x = pBarInsets.left + progressPadding; @@ -271,9 +275,9 @@ y = pBar.getHeight() - pBarInsets.bottom - height - progressPadding; - // When the progress bar is vertical we always paint - // from bottom to top, not matter what the component - // orientation is. + if (SynthLookAndFeel.isLeftToRight(pBar)) { + y -= glowWidth; + } } } } else { @@ -307,8 +311,11 @@ } g.setClip(clip); } else { - context.getPainter().paintProgressBarForeground(context, g, - x, y, width, height, pBar.getOrientation()); + if (minBarSize == null || (width >= minBarSize.width + && height >= minBarSize.height)) { + context.getPainter().paintProgressBarForeground(context, g, + x, y, width, height, pBar.getOrientation()); + } } if (pBar.isStringPainted()) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/javax/swing/plaf/nimbus/8041642/ScrollBarThumbVisibleTest.java Thu Oct 29 19:37:59 2015 +0300 @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2015, 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 8134828 + @summary Scrollbar thumb disappears with Nimbus L&F + @author Semyon Sadetsky +*/ + +import javax.swing.*; +import java.awt.*; + +public class ScrollBarThumbVisibleTest +{ + private static JFrame frame; + private static Point point; + private static JScrollBar bar; + + public static void main(String[] args) throws Exception { + for (UIManager.LookAndFeelInfo info : UIManager + .getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + try { + UIManager.setLookAndFeel(info.getClassName()); + } catch (Exception ex) { + } + break; + } + } + try { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + frame = new JFrame(); + frame.setUndecorated(true); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setup(frame); + } + }); + final Robot robot = new Robot(); + robot.delay(200); + robot.waitForIdle(); + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + point = bar.getLocationOnScreen(); + } + }); + Color color1 = robot.getPixelColor(point.x + 48, point.y + 55); + Color color2 = robot.getPixelColor(point.x + 48, point.y + 125); + System.out.println(color1); + System.out.println(color2); + if (color1.equals(color2)) { + throw new RuntimeException("Thump is not visible"); + } + } finally { + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + frame.dispose(); + } + }); + } + System.out.println("ok"); + } + + static void setup(JFrame frame) { + bar = new JScrollBar(Adjustable.VERTICAL, 500, 0, 0, 1000); + frame.getContentPane().add(bar); + frame.setSize(50, 250); + frame.setLocation(100, 100); + frame.setVisible(true); + } +}