mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-12 06:29:37 +00:00
6718965: Swing color chooser tests should be open source
Reviewed-by: peterz
This commit is contained in:
parent
9d7b3f41e0
commit
ef9b3891fc
78
jdk/test/javax/swing/JColorChooser/Test4165217.java
Normal file
78
jdk/test/javax/swing/JColorChooser/Test4165217.java
Normal file
@ -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();
|
||||
}
|
||||
}
|
||||
95
jdk/test/javax/swing/JColorChooser/Test4177735.java
Normal file
95
jdk/test/javax/swing/JColorChooser/Test4177735.java
Normal file
@ -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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
70
jdk/test/javax/swing/JColorChooser/Test4193384.java
Normal file
70
jdk/test/javax/swing/JColorChooser/Test4193384.java
Normal file
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
60
jdk/test/javax/swing/JColorChooser/Test4234761.java
Normal file
60
jdk/test/javax/swing/JColorChooser/Test4234761.java
Normal file
@ -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");
|
||||
}
|
||||
}
|
||||
17
jdk/test/javax/swing/JColorChooser/Test4380468.html
Normal file
17
jdk/test/javax/swing/JColorChooser/Test4380468.html
Normal file
@ -0,0 +1,17 @@
|
||||
<html>
|
||||
<body>
|
||||
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.
|
||||
|
||||
<applet width="500" height="400" code="Test4380468.class">
|
||||
</applet>
|
||||
</body>
|
||||
</html>
|
||||
40
jdk/test/javax/swing/JColorChooser/Test4380468.java
Normal file
40
jdk/test/javax/swing/JColorChooser/Test4380468.java
Normal file
@ -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));
|
||||
}
|
||||
}
|
||||
46
jdk/test/javax/swing/JColorChooser/Test4461329.java
Normal file
46
jdk/test/javax/swing/JColorChooser/Test4461329.java
Normal file
@ -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()");
|
||||
}
|
||||
}
|
||||
}
|
||||
41
jdk/test/javax/swing/JColorChooser/Test4711996.java
Normal file
41
jdk/test/javax/swing/JColorChooser/Test4711996.java
Normal file
@ -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();
|
||||
}
|
||||
}
|
||||
8
jdk/test/javax/swing/JColorChooser/Test4759306.html
Normal file
8
jdk/test/javax/swing/JColorChooser/Test4759306.html
Normal file
@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<body>
|
||||
If you see the preview panel, then test failed, otherwise it passed.
|
||||
|
||||
<applet width="500" height="400" code="Test4759306.class">
|
||||
</applet>
|
||||
</body>
|
||||
</html>
|
||||
42
jdk/test/javax/swing/JColorChooser/Test4759306.java
Normal file
42
jdk/test/javax/swing/JColorChooser/Test4759306.java
Normal file
@ -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);
|
||||
}
|
||||
}
|
||||
14
jdk/test/javax/swing/JColorChooser/Test4759934.html
Normal file
14
jdk/test/javax/swing/JColorChooser/Test4759934.html
Normal file
@ -0,0 +1,14 @@
|
||||
<html>
|
||||
<body>
|
||||
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.
|
||||
|
||||
<applet width="500" height="400" code="Test4759934.class">
|
||||
</applet>
|
||||
</body>
|
||||
</html>
|
||||
80
jdk/test/javax/swing/JColorChooser/Test4759934.java
Normal file
80
jdk/test/javax/swing/JColorChooser/Test4759934.java
Normal file
@ -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);
|
||||
}
|
||||
}
|
||||
9
jdk/test/javax/swing/JColorChooser/Test4887836.html
Normal file
9
jdk/test/javax/swing/JColorChooser/Test4887836.html
Normal file
@ -0,0 +1,9 @@
|
||||
<html>
|
||||
<body>
|
||||
If you do not see white area under swatches,
|
||||
then test passed, otherwise it failed.
|
||||
|
||||
<applet width="500" height="400" code="Test4887836.class">
|
||||
</applet>
|
||||
</body>
|
||||
</html>
|
||||
43
jdk/test/javax/swing/JColorChooser/Test4887836.java
Normal file
43
jdk/test/javax/swing/JColorChooser/Test4887836.java
Normal file
@ -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));
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user