1
1
/*
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.
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 6587742
26
- * @summary filling half of a JSlider's track is no longer optional
27
- * @author Pavel Porvatov
28
- * @run applet/manual=done bug6587742.html
29
- */
30
-
31
- import javax .swing .*;
24
+ import javax .swing .BoxLayout ;
25
+ import javax .swing .JComboBox ;
26
+ import javax .swing .JFrame ;
27
+ import javax .swing .JLabel ;
28
+ import javax .swing .JOptionPane ;
29
+ import javax .swing .JPanel ;
30
+ import javax .swing .JSlider ;
31
+ import javax .swing .JTabbedPane ;
32
+ import javax .swing .SwingConstants ;
33
+ import javax .swing .SwingUtilities ;
34
+ import javax .swing .UIManager ;
35
+ import javax .swing .UnsupportedLookAndFeelException ;
32
36
import javax .swing .plaf .metal .DefaultMetalTheme ;
33
37
import javax .swing .plaf .metal .MetalLookAndFeel ;
34
38
import javax .swing .plaf .metal .MetalTheme ;
35
39
import javax .swing .plaf .metal .OceanTheme ;
36
40
import java .awt .event .ItemEvent ;
37
41
import java .awt .event .ItemListener ;
38
42
39
- public class bug6587742 extends JApplet {
40
- public void init () {
41
- TestPanel panel = new TestPanel ();
43
+ /* @test
44
+ * @bug 6587742
45
+ * @summary filling half of a JSlider's track is no longer optional
46
+ * @library /java/awt/regtesthelpers
47
+ * @build PassFailJFrame
48
+ * @run main/manual bug6587742
49
+ */
42
50
43
- setContentPane (panel );
51
+ public class bug6587742 {
52
+ private static final String INSTRUCTIONS = """
53
+ Select every theme and check that all sliders looks good.
54
+ Note that every slider has a tooltip text with information about
55
+ slider configuration.
56
+ There is a small difference in sliders with property "filled = null" (it's
57
+ default behaviour when property JSlider.isFilled is not setted)
58
+ for themes:
59
+ 1. OceanTheme - sliders look like filled
60
+ 2. DefaultMetalTheme - sliders look like NOT filled\s """ ;
61
+ private static JFrame frame ;
62
+
63
+ public static void main (String [] args ) throws Exception {
64
+ PassFailJFrame .builder ()
65
+ .title ("JSlider Instructions" )
66
+ .instructions (INSTRUCTIONS )
67
+ .rows (10 )
68
+ .columns (40 )
69
+ .testUI (bug6587742 ::createAndShowUI )
70
+ .build ()
71
+ .awaitAndCheck ();
72
+ }
73
+
74
+ public static JFrame createAndShowUI () {
75
+ frame = new JFrame ("Test Sliders" );
76
+ TestPanel panel = new TestPanel ();
77
+ frame .setSize (800 , 600 );
78
+ frame .getContentPane ().add (panel );
79
+ return frame ;
44
80
}
45
81
46
- private class TestPanel extends JPanel {
82
+ private static class TestPanel extends JPanel {
47
83
private final JComboBox cbThemes = new JComboBox ();
48
84
49
85
private TestPanel () {
@@ -68,30 +104,30 @@ public void itemStateChanged(ItemEvent e) {
68
104
return ;
69
105
}
70
106
71
- SwingUtilities .updateComponentTreeUI (bug6587742 . this );
107
+ SwingUtilities .updateComponentTreeUI (frame );
72
108
}
73
109
}
74
110
});
75
111
76
112
JPanel pnVertical = new JPanel ();
77
113
78
- pnVertical .setLayout (new BoxLayout (pnVertical , BoxLayout .Y_AXIS ));
114
+ pnVertical .setLayout (new BoxLayout (pnVertical , BoxLayout .X_AXIS ));
79
115
80
116
for (int i = 0 ; i < 12 ; i ++) {
81
117
int filled = i >> 2 ;
82
118
83
- pnVertical .add (createSlider (false , filled > 1 ? null : Boolean .valueOf (filled == 1 ), (i & 2 ) == 0 ,
119
+ pnVertical .add (createSlider (true , filled > 1 ? null : Boolean .valueOf (filled == 1 ), (i & 2 ) == 0 ,
84
120
(i & 1 ) != 0 ));
85
121
}
86
122
87
123
JPanel pnHorizontal = new JPanel ();
88
124
89
- pnHorizontal .setLayout (new BoxLayout (pnHorizontal , BoxLayout .X_AXIS ));
125
+ pnHorizontal .setLayout (new BoxLayout (pnHorizontal , BoxLayout .Y_AXIS ));
90
126
91
127
for (int i = 0 ; i < 12 ; i ++) {
92
128
int filled = i >> 2 ;
93
129
94
- pnHorizontal .add (createSlider (true , filled > 1 ? null : Boolean .valueOf (filled == 1 ), (i & 2 ) == 0 ,
130
+ pnHorizontal .add (createSlider (false , filled > 1 ? null : Boolean .valueOf (filled == 1 ), (i & 2 ) == 0 ,
95
131
(i & 1 ) != 0 ));
96
132
}
97
133
0 commit comments