From ec9212ec0a4c0c550a0266cf0ec3c201d0fc8f9c Mon Sep 17 00:00:00 2001 From: malenkov Date: Thu, 26 Jun 2008 15:39:12 +0400 Subject: [PATCH] 6718965: Swing color chooser tests should be open source Reviewed-by: peterz --- .../swing/JColorChooser/Test4165217.java | 78 +++++++++++++++ .../swing/JColorChooser/Test4177735.java | 95 +++++++++++++++++++ .../swing/JColorChooser/Test4193384.java | 70 ++++++++++++++ .../swing/JColorChooser/Test4234761.java | 60 ++++++++++++ .../swing/JColorChooser/Test4380468.html | 17 ++++ .../swing/JColorChooser/Test4380468.java | 40 ++++++++ .../swing/JColorChooser/Test4461329.java | 46 +++++++++ .../swing/JColorChooser/Test4711996.java | 41 ++++++++ .../swing/JColorChooser/Test4759306.html | 8 ++ .../swing/JColorChooser/Test4759306.java | 42 ++++++++ .../swing/JColorChooser/Test4759934.html | 14 +++ .../swing/JColorChooser/Test4759934.java | 80 ++++++++++++++++ .../swing/JColorChooser/Test4887836.html | 9 ++ .../swing/JColorChooser/Test4887836.java | 43 +++++++++ 14 files changed, 643 insertions(+) create mode 100644 test/javax/swing/JColorChooser/Test4165217.java create mode 100644 test/javax/swing/JColorChooser/Test4177735.java create mode 100644 test/javax/swing/JColorChooser/Test4193384.java create mode 100644 test/javax/swing/JColorChooser/Test4234761.java create mode 100644 test/javax/swing/JColorChooser/Test4380468.html create mode 100644 test/javax/swing/JColorChooser/Test4380468.java create mode 100644 test/javax/swing/JColorChooser/Test4461329.java create mode 100644 test/javax/swing/JColorChooser/Test4711996.java create mode 100644 test/javax/swing/JColorChooser/Test4759306.html create mode 100644 test/javax/swing/JColorChooser/Test4759306.java create mode 100644 test/javax/swing/JColorChooser/Test4759934.html create mode 100644 test/javax/swing/JColorChooser/Test4759934.java create mode 100644 test/javax/swing/JColorChooser/Test4887836.html create mode 100644 test/javax/swing/JColorChooser/Test4887836.java diff --git a/test/javax/swing/JColorChooser/Test4165217.java b/test/javax/swing/JColorChooser/Test4165217.java new file mode 100644 index 000000000..59a80e898 --- /dev/null +++ b/test/javax/swing/JColorChooser/Test4165217.java @@ -0,0 +1,78 @@ +/* + * Copyright 2003-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 4165217 + * @summary Tests JColorChooser serialization + * @author Ilya Boyandin + */ + +import java.awt.Color; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.Random; +import javax.swing.JColorChooser; + +public class Test4165217 { + public static void main(String[] args) { + JColorChooser chooser = new JColorChooser(); + chooser.setColor(new Color(new Random().nextInt())); + + Color before = chooser.getColor(); + Color after = copy(chooser).getColor(); + + if (!after.equals(before)) { + throw new Error("color is changed after serialization"); + } + } + + private static JColorChooser copy(JColorChooser chooser) { + try { + return (JColorChooser) deserialize(serialize(chooser)); + } + catch (ClassNotFoundException exception) { + throw new Error("unexpected exception during class creation", exception); + } + catch (IOException exception) { + throw new Error("unexpected exception during serialization", exception); + } + } + + private static byte[] serialize(Object object) throws IOException { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ObjectOutputStream oos = new ObjectOutputStream(baos); + oos.writeObject(object); + oos.flush(); + return baos.toByteArray(); + } + + private static Object deserialize(byte[] array) throws IOException, ClassNotFoundException { + ByteArrayInputStream bais = new ByteArrayInputStream(array); + ObjectInputStream ois = new ObjectInputStream(bais); + return ois.readObject(); + } +} diff --git a/test/javax/swing/JColorChooser/Test4177735.java b/test/javax/swing/JColorChooser/Test4177735.java new file mode 100644 index 000000000..b8b2d93f4 --- /dev/null +++ b/test/javax/swing/JColorChooser/Test4177735.java @@ -0,0 +1,95 @@ +/* + * Copyright 2002-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 4177735 + * @summary Tests that JColorChooser leaves no threads when disposed + * @author Shannon Hickey + */ + +import java.awt.Point; +import javax.swing.JColorChooser; +import javax.swing.JDialog; +import javax.swing.SwingUtilities; +import javax.swing.colorchooser.AbstractColorChooserPanel; + +public class Test4177735 implements Runnable { + private static final long DELAY = 1000L; + + public static void main(String[] args) throws Exception { + JColorChooser chooser = new JColorChooser(); + AbstractColorChooserPanel[] panels = chooser.getChooserPanels(); + chooser.setChooserPanels(new AbstractColorChooserPanel[] { panels[1] }); + + JDialog dialog = show(chooser); + pause(DELAY); + + dialog.dispose(); + pause(DELAY); + + Test4177735 test = new Test4177735(); + SwingUtilities.invokeAndWait(test); + if (test.count != 0) { + throw new Error("JColorChooser leaves " + test.count + " threads running"); + } + } + + static JDialog show(JColorChooser chooser) { + JDialog dialog = JColorChooser.createDialog(null, null, false, chooser, null, null); + dialog.setVisible(true); + // block till displayed + Point point = null; + while (point == null) { + try { + point = dialog.getLocationOnScreen(); + } + catch (IllegalStateException exception) { + pause(DELAY); + } + } + return dialog; + } + + private static void pause(long delay) { + try { + Thread.sleep(delay); + } + catch (InterruptedException exception) { + } + } + + private int count; + + public void run() { + ThreadGroup group = Thread.currentThread().getThreadGroup(); + Thread[] threads = new Thread[group.activeCount()]; + int count = group.enumerate(threads, false); + for (int i = 0; i < count; i++) { + String name = threads[i].getName(); + if ("SyntheticImageGenerator".equals(name)) { // NON-NLS: thread name + this.count++; + } + } + } +} diff --git a/test/javax/swing/JColorChooser/Test4193384.java b/test/javax/swing/JColorChooser/Test4193384.java new file mode 100644 index 000000000..e9ed74728 --- /dev/null +++ b/test/javax/swing/JColorChooser/Test4193384.java @@ -0,0 +1,70 @@ +/* + * Copyright 2000-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 4193384 4200976 + * @summary Tests the color conversions and the preview panel foreground color + * @author Mark Davidson + */ + +import java.awt.Color; +import javax.swing.JColorChooser; +import javax.swing.JLabel; + +public class Test4193384 { + public static void main(String[] args) { + test(new Color[] { + new Color(11, 12, 13), + new Color(204, 0, 204), + new Color(0, 51, 51) + }); + } + + private static void test(Color[] colors) { + JLabel label = new JLabel("Preview Panel"); // NON-NLS: simple label + + JColorChooser chooser = new JColorChooser(); + chooser.setPreviewPanel(label); + + float[] hsb = new float[3]; + for (int i = 0; i < colors.length; i++) { + Color color = colors[i]; + // Make sure sure that there wasn't a regression + // in java.awt.Color and the conversion methods + Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), hsb); + if (!color.equals(Color.getHSBColor(hsb[0], hsb[1], hsb[2]))) { + throw new Error("color conversion is failed"); + } + // 4193384 regression test + if (!color.equals(new JColorChooser(color).getColor())) { + throw new Error("constructor sets incorrect initial color"); + } + // 4200976 regression test + chooser.setColor(color); + if (!color.equals(label.getForeground())) { + throw new Error("a custom preview panel doesn't handle colors"); + } + } + } +} diff --git a/test/javax/swing/JColorChooser/Test4234761.java b/test/javax/swing/JColorChooser/Test4234761.java new file mode 100644 index 000000000..aa3d972a6 --- /dev/null +++ b/test/javax/swing/JColorChooser/Test4234761.java @@ -0,0 +1,60 @@ +/* + * Copyright 2002-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 4234761 + * @summary RGB values sholdn't be changed in transition to HSB tab + * @author Oleg Mokhovikov + */ + +import java.awt.Color; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import javax.swing.JColorChooser; +import javax.swing.JDialog; +import javax.swing.JTabbedPane; + +public class Test4234761 implements PropertyChangeListener { + private static final Color COLOR = new Color(51, 51, 51); + + public static void main(String[] args) { + JColorChooser chooser = new JColorChooser(COLOR); + JDialog dialog = Test4177735.show(chooser); + + PropertyChangeListener listener = new Test4234761(); + chooser.addPropertyChangeListener("color", listener); // NON-NLS: property name + + JTabbedPane tabbedPane = (JTabbedPane) chooser.getComponent(0); + tabbedPane.setSelectedIndex(1); // HSB tab index + + if (!chooser.getColor().equals(COLOR)) { + listener.propertyChange(null); + } + dialog.dispose(); + } + + public void propertyChange(PropertyChangeEvent event) { + throw new Error("RGB value is changed after transition to HSB tab"); + } +} diff --git a/test/javax/swing/JColorChooser/Test4380468.html b/test/javax/swing/JColorChooser/Test4380468.html new file mode 100644 index 000000000..fbbba0d2e --- /dev/null +++ b/test/javax/swing/JColorChooser/Test4380468.html @@ -0,0 +1,17 @@ + + +1. Click the HSB tab at the ColorChooser. +2. Click in the lower left corner of the gradient palette + in order to select a color such that all three RGB values + are single digit colors (such as 0, 0, 0 or 5, 3, 1). +3. Click another tab, then click back to the HSB tab. +4. Now click the lighter colors that should have + 2 and 3 digit RGB values (in the upper right corner). + +If all digits of each RGB value are shown then test passes. +If only the last digit of their values are shown then test fails. + + + + + diff --git a/test/javax/swing/JColorChooser/Test4380468.java b/test/javax/swing/JColorChooser/Test4380468.java new file mode 100644 index 000000000..7e9033171 --- /dev/null +++ b/test/javax/swing/JColorChooser/Test4380468.java @@ -0,0 +1,40 @@ +/* + * Copyright 2000-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 4380468 + * @summary JColorChooser's HSB panel should display all RGB digits + * @author Andrey Pikalev + * @run applet/manual=yesno Test4380468.html + */ + +import java.awt.Color; +import javax.swing.JApplet; +import javax.swing.JColorChooser; + +public class Test4380468 extends JApplet { + public void init() { + add(new JColorChooser(Color.GREEN)); + } +} diff --git a/test/javax/swing/JColorChooser/Test4461329.java b/test/javax/swing/JColorChooser/Test4461329.java new file mode 100644 index 000000000..2f23bc1ec --- /dev/null +++ b/test/javax/swing/JColorChooser/Test4461329.java @@ -0,0 +1,46 @@ +/* + * Copyright 2002-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 4461329 + * @summary Tests getPreviewPanel() and setPreviewPanel() methods + * @author Leif Samuelsson + */ + +import javax.swing.JButton; +import javax.swing.JColorChooser; + +public class Test4461329 { + public static void main(String[] args) { + JColorChooser chooser = new JColorChooser(); + if (null == chooser.getPreviewPanel()) { + throw new Error("Failed: getPreviewPanel() returned null"); + } + JButton button = new JButton("Color"); // NON-NLS: simple label + chooser.setPreviewPanel(button); + if (button != chooser.getPreviewPanel()) { + throw new Error("Failed in setPreviewPanel()"); + } + } +} diff --git a/test/javax/swing/JColorChooser/Test4711996.java b/test/javax/swing/JColorChooser/Test4711996.java new file mode 100644 index 000000000..fb6007712 --- /dev/null +++ b/test/javax/swing/JColorChooser/Test4711996.java @@ -0,0 +1,41 @@ +/* + * Copyright 2003-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 4711996 + * @summary Checks if IllegalArgumentException is thrown when updating JColorChooserUI + * @author Konstantin Eremin + */ + +import javax.swing.JColorChooser; +import javax.swing.colorchooser.AbstractColorChooserPanel; + +public class Test4711996 { + public static void main(String[] args) { + JColorChooser chooser = new JColorChooser(); + AbstractColorChooserPanel[] panels = chooser.getChooserPanels(); + chooser.removeChooserPanel(panels[0]); + chooser.updateUI(); + } +} diff --git a/test/javax/swing/JColorChooser/Test4759306.html b/test/javax/swing/JColorChooser/Test4759306.html new file mode 100644 index 000000000..8a4d53f00 --- /dev/null +++ b/test/javax/swing/JColorChooser/Test4759306.html @@ -0,0 +1,8 @@ + + +If you see the preview panel, then test failed, otherwise it passed. + + + + + diff --git a/test/javax/swing/JColorChooser/Test4759306.java b/test/javax/swing/JColorChooser/Test4759306.java new file mode 100644 index 000000000..726ed798f --- /dev/null +++ b/test/javax/swing/JColorChooser/Test4759306.java @@ -0,0 +1,42 @@ +/* + * Copyright 2002-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 4759306 + * @summary Checks if JColorChooser.setPreviewPanel removes the old one + * @author Konstantin Eremin + @run applet/manual=yesno Test4759306.html + */ + +import javax.swing.JApplet; +import javax.swing.JColorChooser; +import javax.swing.JPanel; + +public class Test4759306 extends JApplet { + public void init() { + JColorChooser chooser = new JColorChooser(); + chooser.setPreviewPanel(new JPanel()); + getContentPane().add(chooser); + } +} diff --git a/test/javax/swing/JColorChooser/Test4759934.html b/test/javax/swing/JColorChooser/Test4759934.html new file mode 100644 index 000000000..0441b67ac --- /dev/null +++ b/test/javax/swing/JColorChooser/Test4759934.html @@ -0,0 +1,14 @@ + + +1. Press button "Show Dialog" at the frame "Test" and + the dialog with button "Show ColorChooser" should appears. +2. Press button "Show ColorChooser" at the dialog "Dialog" and + the colorchooser should appears. +3. Press the button "Cancel" of colorchooser. + If the focus will come to the frame "Test" then test fails. + If the focus will come to the dialog "Dialog" then test passes. + + + + + diff --git a/test/javax/swing/JColorChooser/Test4759934.java b/test/javax/swing/JColorChooser/Test4759934.java new file mode 100644 index 000000000..27137726e --- /dev/null +++ b/test/javax/swing/JColorChooser/Test4759934.java @@ -0,0 +1,80 @@ +/* + * Copyright 2003-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 4759934 + * @summary Tests windows activation problem + * @author Andrey Pikalev + * @run applet/manual=yesno Test4759934.html + */ + +import java.awt.Color; +import java.awt.Component; +import java.awt.Window; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import javax.swing.JApplet; +import javax.swing.JButton; +import javax.swing.JColorChooser; +import javax.swing.JDialog; +import javax.swing.JFrame; + +public class Test4759934 extends JApplet implements ActionListener { + private static final String CMD_DIALOG = "Show Dialog"; // NON-NLS: first button + private static final String CMD_CHOOSER = "Show ColorChooser"; // NON-NLS: second button + + private final JFrame frame = new JFrame("Test"); // NON-NLS: frame title + + public void init() { + show(this.frame, CMD_DIALOG); + } + + public void actionPerformed(ActionEvent event) { + String command = event.getActionCommand(); + if (CMD_DIALOG.equals(command)) { + JDialog dialog = new JDialog(this.frame, "Dialog"); // NON-NLS: dialog title + dialog.setLocation(200, 0); + show(dialog, CMD_CHOOSER); + } + else if (CMD_CHOOSER.equals(command)) { + Object source = event.getSource(); + Component component = (source instanceof Component) + ? (Component) source + : null; + + JColorChooser.showDialog(component, "ColorChooser", Color.BLUE); // NON-NLS: title + } + } + + private void show(Window window, String command) { + JButton button = new JButton(command); + button.setActionCommand(command); + button.addActionListener(this); + button.setFont(button.getFont().deriveFont(64.0f)); + + window.add(button); + window.pack(); + window.setVisible(true); + } +} diff --git a/test/javax/swing/JColorChooser/Test4887836.html b/test/javax/swing/JColorChooser/Test4887836.html new file mode 100644 index 000000000..324d5afe3 --- /dev/null +++ b/test/javax/swing/JColorChooser/Test4887836.html @@ -0,0 +1,9 @@ + + +If you do not see white area under swatches, +then test passed, otherwise it failed. + + + + + diff --git a/test/javax/swing/JColorChooser/Test4887836.java b/test/javax/swing/JColorChooser/Test4887836.java new file mode 100644 index 000000000..3c6bb3832 --- /dev/null +++ b/test/javax/swing/JColorChooser/Test4887836.java @@ -0,0 +1,43 @@ +/* + * Copyright 2003-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 4887836 + * @summary Checks if no tooltip modification when no KeyStroke modifier + * @author Konstantin Eremin + * @run applet/manual=yesno Test4887836.html + */ + +import java.awt.Color; +import java.awt.Font; +import javax.swing.JApplet; +import javax.swing.JColorChooser; +import javax.swing.UIManager; + +public class Test4887836 extends JApplet { + public void init() { + UIManager.put("Label.font", new Font("Perpetua", 0, 36)); // NON-NLS: property and font names + add(new JColorChooser(Color.LIGHT_GRAY)); + } +} -- GitLab