--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/swing/JButton/6604281/bug6604281.java Mon Aug 11 16:39:17 2008 +0400
@@ -0,0 +1,76 @@
+/*
+ * 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);
+ }
+}