提交 b1d4d370 编写于 作者: R rupashka

6604281: NimbusL&F :Regression in Focus traversal in JFileChooser in pit build.

Summary: Fixed calculation of preferred size in SynthButtonUI
Reviewed-by: loneid, peterz
上级 e9fb2320
...@@ -262,7 +262,7 @@ class SynthButtonUI extends BasicButtonUI implements ...@@ -262,7 +262,7 @@ class SynthButtonUI extends BasicButtonUI implements
* Returns the default icon. This should NOT callback * Returns the default icon. This should NOT callback
* to the JComponent. * to the JComponent.
* *
* @param b AbstractButton the iocn is associated with * @param b AbstractButton the icon is associated with
* @return default icon * @return default icon
*/ */
...@@ -445,9 +445,7 @@ class SynthButtonUI extends BasicButtonUI implements ...@@ -445,9 +445,7 @@ class SynthButtonUI extends BasicButtonUI implements
* Returns the Icon used in calculating the pref/min/max size. * Returns the Icon used in calculating the pref/min/max size.
*/ */
protected Icon getSizingIcon(AbstractButton b) { protected Icon getSizingIcon(AbstractButton b) {
// NOTE: this is slightly different than BasicButtonUI, where it Icon icon = getEnabledIcon(b, b.getIcon());
// would just use getIcon, but this should be ok.
Icon icon = (b.isEnabled()) ? b.getIcon() : b.getDisabledIcon();
if (icon == null) { if (icon == null) {
icon = getDefaultIcon(b); icon = getDefaultIcon(b);
} }
......
/*
* Copyright 2008 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/* @test
@bug 6604281
@summary NimbusL&F :Regression in Focus traversal in JFileChooser in pit build
@author Pavel Porvatov
@run main bug6604281
*/
import javax.swing.*;
import javax.swing.plaf.IconUIResource;
import javax.swing.plaf.synth.SynthLookAndFeel;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.lang.reflect.InvocationTargetException;
public class bug6604281 {
public static void main(String[] args) throws InvocationTargetException, InterruptedException {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
SynthLookAndFeel laf = new SynthLookAndFeel();
try {
UIManager.setLookAndFeel(laf);
} catch (Exception e) {
fail(e.getMessage());
}
// Prepare image
BufferedImage image = new BufferedImage(32, 32, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = (Graphics2D) image.getGraphics();
graphics.setColor(Color.BLUE);
graphics.fillRect(0, 0, image.getWidth(), image.getHeight());
graphics.setColor(Color.RED);
graphics.drawLine(0, 0, image.getWidth(), image.getHeight());
// Use IconUIResource as an icon, because with ImageIcon bug is not reproduced
JButton button1 = new JButton(new IconUIResource(new ImageIcon(image)));
JButton button2 = new JButton(new IconUIResource(new ImageIcon(image)));
button2.setEnabled(false);
if (button1.getPreferredSize().getHeight() != button2.getPreferredSize().getHeight()) {
fail("Two similar buttons have different size");
}
}
});
}
private static void fail(String s) {
throw new RuntimeException("Test failed: " + s);
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册