Skip to content

Commit 34d3185

Browse files
committed
8327857: Remove applet usage from JColorChooser tests Test4222508
Backport-of: 7c6fd337d00d4bdeaac724a6ea26fac3654846e0
1 parent 2c64d33 commit 34d3185

File tree

2 files changed

+36
-54
lines changed

2 files changed

+36
-54
lines changed

test/jdk/javax/swing/JColorChooser/Test4222508.html

Lines changed: 0 additions & 32 deletions
This file was deleted.
Lines changed: 36 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 2024 Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -21,36 +21,50 @@
2121
* questions.
2222
*/
2323

24+
import java.awt.BorderLayout;
25+
import javax.swing.JCheckBox;
26+
import javax.swing.JColorChooser;
27+
import javax.swing.JFrame;
28+
2429
/*
2530
* @test
2631
* @bug 4222508
32+
* @library /java/awt/regtesthelpers
33+
* @build PassFailJFrame
2734
* @summary Tests the color chooser disabling
28-
* @author Sergey Malenkov
29-
* @run applet/manual=yesno Test4222508.html
35+
* @run main/manual Test4222508
3036
*/
37+
public final class Test4222508 {
3138

32-
import java.awt.BorderLayout;
33-
import java.awt.event.ItemEvent;
34-
import java.awt.event.ItemListener;
35-
import javax.swing.JApplet;
36-
import javax.swing.JCheckBox;
37-
import javax.swing.JColorChooser;
39+
public static void main(String[] args) throws Exception {
40+
String instructions = "Click on colors in the JColorChooser.\n" +
41+
"Then uncheck the checkbox and click on colors again.\n" +
42+
"If the JColorChooser is disabled when the checkbox is unchecked, " +
43+
"then pass the test.";
3844

39-
public final class Test4222508 extends JApplet implements ItemListener {
45+
PassFailJFrame.builder()
46+
.title("Test4222508")
47+
.instructions(instructions)
48+
.rows(5)
49+
.columns(40)
50+
.testTimeOut(10)
51+
.testUI(Test4222508::test)
52+
.build()
53+
.awaitAndCheck();
54+
}
4055

41-
private JCheckBox checkbox;
42-
private JColorChooser chooser;
56+
public static JFrame test() {
57+
JFrame frame = new JFrame("JColorChooser with enable/disable checkbox");
58+
frame.setLayout(new BorderLayout());
59+
JColorChooser chooser = new JColorChooser();
60+
JCheckBox checkbox = new JCheckBox("Enable the color chooser below", true);
61+
checkbox.addItemListener(e -> chooser.setEnabled(checkbox.isSelected()));
4362

44-
@Override
45-
public void init() {
46-
this.chooser = new JColorChooser();
47-
this.checkbox = new JCheckBox("Enable the color chooser below", true);
48-
this.checkbox.addItemListener(this);
49-
add(BorderLayout.NORTH, this.checkbox);
50-
add(BorderLayout.CENTER, this.chooser);
51-
}
63+
frame.add(chooser, BorderLayout.SOUTH);
64+
frame.add(checkbox, BorderLayout.NORTH);
65+
frame.pack();
5266

53-
public void itemStateChanged(ItemEvent event) {
54-
this.chooser.setEnabled(this.checkbox.isSelected());
67+
return frame;
5568
}
69+
5670
}

0 commit comments

Comments
 (0)