提交 ec210184 编写于 作者: A aivanov

8134828: Scrollbar thumb disappears with Nimbus L&F

Reviewed-by: alexsch, alexp
上级 8054c83c
......@@ -625,10 +625,6 @@ public abstract class AbstractRegionPainter implements Painter<JComponent> {
// 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);
......
<?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>
/*
* 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 @@ public class SynthProgressBarUI extends BasicProgressBarUI
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 @@ public class SynthProgressBarUI extends BasicProgressBarUI
tileWidth *= 0.784;
}
}
minBarSize = (Dimension)style.get(context, "ProgressBar.minBarSize");
glowWidth = style.getInt(context, "ProgressBar.glowWidth", 0);
context.dispose();
}
......@@ -258,7 +262,7 @@ public class SynthProgressBarUI extends BasicProgressBarUI
if (!SynthLookAndFeel.isLeftToRight(pBar)) {
x = pBar.getWidth() - pBarInsets.right - width
- progressPadding;
- progressPadding - glowWidth;
}
} else { // JProgressBar.VERTICAL
x = pBarInsets.left + progressPadding;
......@@ -271,9 +275,9 @@ public class SynthProgressBarUI extends BasicProgressBarUI
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 @@ public class SynthProgressBarUI extends BasicProgressBarUI
}
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()) {
......
/*
* 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);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册