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
2121 * questions.
2222 */
2323
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 ;
3236import javax .swing .plaf .metal .DefaultMetalTheme ;
3337import javax .swing .plaf .metal .MetalLookAndFeel ;
3438import javax .swing .plaf .metal .MetalTheme ;
3539import javax .swing .plaf .metal .OceanTheme ;
3640import java .awt .event .ItemEvent ;
3741import java .awt .event .ItemListener ;
3842
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+ */
4250
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 ;
4480 }
4581
46- private class TestPanel extends JPanel {
82+ private static class TestPanel extends JPanel {
4783 private final JComboBox cbThemes = new JComboBox ();
4884
4985 private TestPanel () {
@@ -68,30 +104,30 @@ public void itemStateChanged(ItemEvent e) {
68104 return ;
69105 }
70106
71- SwingUtilities .updateComponentTreeUI (bug6587742 . this );
107+ SwingUtilities .updateComponentTreeUI (frame );
72108 }
73109 }
74110 });
75111
76112 JPanel pnVertical = new JPanel ();
77113
78- pnVertical .setLayout (new BoxLayout (pnVertical , BoxLayout .Y_AXIS ));
114+ pnVertical .setLayout (new BoxLayout (pnVertical , BoxLayout .X_AXIS ));
79115
80116 for (int i = 0 ; i < 12 ; i ++) {
81117 int filled = i >> 2 ;
82118
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 ,
84120 (i & 1 ) != 0 ));
85121 }
86122
87123 JPanel pnHorizontal = new JPanel ();
88124
89- pnHorizontal .setLayout (new BoxLayout (pnHorizontal , BoxLayout .X_AXIS ));
125+ pnHorizontal .setLayout (new BoxLayout (pnHorizontal , BoxLayout .Y_AXIS ));
90126
91127 for (int i = 0 ; i < 12 ; i ++) {
92128 int filled = i >> 2 ;
93129
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 ,
95131 (i & 1 ) != 0 ));
96132 }
97133
0 commit comments