1
1
/*
2
- * Copyright (c) 2007, 2018 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2007, 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
- /* @test
25
- @bug 4987336
26
- @summary JSlider doesn't show label's animated icon.
27
- @author Pavel Porvatov
28
- @run applet/manual=done bug4987336.html
24
+ /*
25
+ * @test
26
+ * @bug 4987336
27
+ * @summary JSlider doesn't show label's animated icon.
28
+ * @library /java/awt/regtesthelpers
29
+ * @build PassFailJFrame
30
+ * @run main/manual bug4987336
29
31
*/
30
-
31
- import javax .swing .*;
32
- import javax .swing .border .TitledBorder ;
33
32
import java .awt .event .ActionEvent ;
34
33
import java .awt .event .ActionListener ;
34
+ import javax .swing .ButtonGroup ;
35
+ import javax .swing .BoxLayout ;
36
+ import javax .swing .ImageIcon ;
37
+ import javax .swing .JComponent ;
38
+ import javax .swing .JFrame ;
39
+ import javax .swing .JLabel ;
40
+ import javax .swing .JPanel ;
41
+ import javax .swing .JRadioButton ;
42
+ import javax .swing .JScrollPane ;
43
+ import javax .swing .JSlider ;
44
+ import javax .swing .SwingConstants ;
45
+ import javax .swing .SwingUtilities ;
46
+ import javax .swing .UIManager ;
47
+ import javax .swing .border .TitledBorder ;
35
48
import java .util .Hashtable ;
36
49
37
- public class bug4987336 extends JApplet {
50
+ public class bug4987336 {
51
+ private static final String INSTRUCTIONS = """
52
+ There are four Sliders.
53
+ Each of them has a label with animated gif (a waving duke)
54
+ and a label with static image.
55
+ If it is rendered correctly, click Pass else click Fail.""" ;
56
+
38
57
private static final String IMAGE_RES = "box.gif" ;
39
58
40
59
private static final String ANIM_IMAGE_RES = "duke.gif" ;
60
+ private static JFrame frame ;
61
+
62
+ public static void main (String [] args ) throws Exception {
63
+ PassFailJFrame .builder ()
64
+ .title ("Slider rendering Instructions" )
65
+ .instructions (INSTRUCTIONS )
66
+ .rows (5 )
67
+ .columns (35 )
68
+ .testUI (bug4987336 ::createTestUI )
69
+ .position (PassFailJFrame .Position .TOP_LEFT_CORNER )
70
+ .build ()
71
+ .awaitAndCheck ();
72
+ }
41
73
42
- public void init () {
74
+ private static JFrame createTestUI () {
75
+ frame = new JFrame ("bug4987336" );
43
76
JPanel pnLafs = new JPanel ();
44
77
pnLafs .setLayout (new BoxLayout (pnLafs , BoxLayout .Y_AXIS ));
45
78
@@ -64,7 +97,9 @@ public void init() {
64
97
pnContent .add (createSlider (true , ANIM_IMAGE_RES , null , IMAGE_RES , IMAGE_RES ));
65
98
pnContent .add (createSlider (false , ANIM_IMAGE_RES , null , IMAGE_RES , IMAGE_RES ));
66
99
67
- getContentPane ().add (new JScrollPane (pnContent ));
100
+ frame .getContentPane ().add (new JScrollPane (pnContent ));
101
+ frame .pack ();
102
+ return frame ;
68
103
}
69
104
70
105
private static JSlider createSlider (boolean enabled ,
@@ -99,7 +134,7 @@ private static JLabel createLabel(String enabledImage, String disabledImage) {
99
134
return result ;
100
135
}
101
136
102
- private class LafRadioButton extends JRadioButton {
137
+ private static class LafRadioButton extends JRadioButton {
103
138
public LafRadioButton (final UIManager .LookAndFeelInfo lafInfo ) {
104
139
super (lafInfo .getName (), lafInfo .getName ().equals (UIManager .getLookAndFeel ().getName ()));
105
140
@@ -108,7 +143,7 @@ public void actionPerformed(ActionEvent e) {
108
143
try {
109
144
UIManager .setLookAndFeel (lafInfo .getClassName ());
110
145
111
- SwingUtilities .updateComponentTreeUI (bug4987336 . this );
146
+ SwingUtilities .updateComponentTreeUI (frame );
112
147
} catch (Exception ex ) {
113
148
// Ignore such errors
114
149
System .out .println ("Cannot set LAF " + lafInfo .getName ());
0 commit comments