|
1 | 1 | /* |
2 | | - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
|
21 | 21 | * questions. |
22 | 22 | */ |
23 | 23 |
|
| 24 | +import java.awt.Color; |
| 25 | +import javax.swing.JColorChooser; |
| 26 | +import javax.swing.JLabel; |
| 27 | + |
24 | 28 | /* |
25 | 29 | * @test |
26 | 30 | * @bug 6977726 |
27 | | - * @summary Checks if JColorChooser.setPreviewPanel removes the old one |
28 | | - * @author Sergey Malenkov |
29 | | - * @run applet/manual=yesno Test6977726.html |
| 31 | + * @library /java/awt/regtesthelpers |
| 32 | + * @build PassFailJFrame |
| 33 | + * @summary Checks if JColorChooser.setPreviewPanel(JLabel) doesn't remove the preview panel but |
| 34 | + * removes the content of the default preview panel |
| 35 | + * @run main/manual Test6977726 |
30 | 36 | */ |
31 | 37 |
|
32 | | -import javax.swing.JApplet; |
33 | | -import javax.swing.JColorChooser; |
34 | | -import javax.swing.JLabel; |
| 38 | +public class Test6977726 { |
| 39 | + |
| 40 | + public static void main(String[] args) throws Exception { |
| 41 | + String instructions = """ |
| 42 | + Check that there is a panel with "Text Preview Panel" text |
| 43 | + and with title "Preview" in the JColorChooser. |
| 44 | + Test passes if the panel is as described, test fails otherwise."""; |
| 45 | + |
| 46 | + PassFailJFrame.builder() |
| 47 | + .title("Test6977726") |
| 48 | + .instructions(instructions) |
| 49 | + .rows(5) |
| 50 | + .columns(40) |
| 51 | + .testTimeOut(2) |
| 52 | + .testUI(Test6977726::createColorChooser) |
| 53 | + .build() |
| 54 | + .awaitAndCheck(); |
| 55 | + } |
35 | 56 |
|
36 | | -public class Test6977726 extends JApplet { |
37 | | - public void init() { |
38 | | - JColorChooser chooser = new JColorChooser(); |
| 57 | + private static JColorChooser createColorChooser() { |
| 58 | + JColorChooser chooser = new JColorChooser(Color.BLUE); |
39 | 59 | chooser.setPreviewPanel(new JLabel("Text Preview Panel")); |
40 | | - getContentPane().add(chooser); |
| 60 | + return chooser; |
41 | 61 | } |
42 | 62 | } |
0 commit comments