Skip to content

Commit 7478c4b

Browse files
committed
8328380: Remove applet usage from JColorChooser tests Test6348456
Backport-of: 78d1b9046830198cd61c505f04f245a430878a5b
1 parent 8c58f66 commit 7478c4b

File tree

2 files changed

+48
-56
lines changed

2 files changed

+48
-56
lines changed

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

Lines changed: 0 additions & 32 deletions
This file was deleted.
Lines changed: 48 additions & 24 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,43 +21,67 @@
2121
* questions.
2222
*/
2323

24-
/*
25-
* @test
26-
* @bug 6348456
27-
* @summary Tests model changing
28-
* @author Sergey Malenkov
29-
* @run applet/manual=yesno Test6348456.html
30-
*/
31-
3224
import java.awt.BorderLayout;
3325
import java.awt.Color;
3426
import java.awt.event.ActionEvent;
3527
import java.awt.event.ActionListener;
36-
import javax.swing.JApplet;
3728
import javax.swing.JButton;
3829
import javax.swing.JColorChooser;
30+
import javax.swing.JFrame;
3931
import javax.swing.colorchooser.DefaultColorSelectionModel;
4032

41-
public final class Test6348456 extends JApplet implements ActionListener {
33+
/*
34+
* @test
35+
* @bug 6348456
36+
* @library /java/awt/regtesthelpers
37+
* @build PassFailJFrame
38+
* @summary Tests model changing
39+
* @run main/manual Test6348456
40+
*/
4241

43-
private static final DefaultColorSelectionModel WHITE = new DefaultColorSelectionModel(Color.WHITE);
44-
private static final DefaultColorSelectionModel BLACK = new DefaultColorSelectionModel(Color.BLACK);
42+
public final class Test6348456 {
4543

46-
private JColorChooser chooser;
44+
private static final DefaultColorSelectionModel WHITE =
45+
new DefaultColorSelectionModel(Color.WHITE);
46+
private static final DefaultColorSelectionModel BLACK =
47+
new DefaultColorSelectionModel(Color.BLACK);
4748

48-
@Override
49-
public void init() {
50-
JButton button = new JButton("Swap models");
51-
button.addActionListener(this);
49+
private static JColorChooser chooser;
5250

53-
this.chooser = new JColorChooser(Color.RED);
54-
this.chooser.setSelectionModel(WHITE);
51+
public static void main(String[] args) throws Exception {
52+
String instructions = "When test starts, you'll see that the preview is white.\n" +
53+
"When you swap models, you'll see that the preview color is changed.\n" +
54+
"Click pass if so, otherwise fail.";
5555

56-
add(BorderLayout.NORTH, button);
57-
add(BorderLayout.CENTER, this.chooser);
56+
PassFailJFrame.builder()
57+
.title("Test6348456")
58+
.instructions(instructions)
59+
.rows(5)
60+
.columns(40)
61+
.testTimeOut(10)
62+
.testUI(Test6348456::test)
63+
.build()
64+
.awaitAndCheck();
5865
}
5966

60-
public void actionPerformed(ActionEvent event){
61-
this.chooser.setSelectionModel(this.chooser.getSelectionModel() == BLACK ? WHITE : BLACK);
67+
public static JFrame test() {
68+
JFrame frame = new JFrame("JColor Swap Models Test");
69+
JButton button = new JButton("Swap models");
70+
button.addActionListener(new ActionListener() {
71+
@Override
72+
public void actionPerformed(ActionEvent event) {
73+
chooser.setSelectionModel(chooser.getSelectionModel() == BLACK ? WHITE : BLACK);
74+
75+
}
76+
});
77+
78+
chooser = new JColorChooser(Color.RED);
79+
chooser.setSelectionModel(WHITE);
80+
81+
frame.add(BorderLayout.NORTH, button);
82+
frame.add(BorderLayout.CENTER, chooser);
83+
frame.pack();
84+
85+
return frame;
6286
}
6387
}

0 commit comments

Comments
 (0)