Skip to content

Commit 5f2a92d

Browse files
author
Abhishek Kumar
committedMar 19, 2024
8328244: Convert javax/swing/JSlider/6742358/bug6742358.java applet test to main
Reviewed-by: psadhukhan, tr
1 parent 2094ff3 commit 5f2a92d

File tree

2 files changed

+42
-57
lines changed

2 files changed

+42
-57
lines changed
 

‎test/jdk/javax/swing/JSlider/6742358/bug6742358.html

-29
This file was deleted.

‎test/jdk/javax/swing/JSlider/6742358/bug6742358.java ‎test/jdk/javax/swing/JSlider/bug6742358.java

+42-28
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,37 +21,46 @@
2121
* questions.
2222
*/
2323

24-
/* @test
24+
/*
25+
* @test
2526
* @bug 6742358
26-
* @summary MetalSliderUI paint wrong vertical disabled filled JSlider for DefaultMetalTheme
27-
* @author Pavel Porvatov
28-
* @run applet/manual=done bug6742358.html
27+
* @summary Verifies that painting a vertical disabled filled JSlider, the
28+
* track will be painted correctly for DefaultMetalTheme.
29+
* @library /java/awt/regtesthelpers
30+
* @build PassFailJFrame
31+
* @run main/manual bug6742358
2932
*/
3033

31-
import javax.swing.*;
34+
import javax.swing.BoxLayout;
35+
import javax.swing.JFrame;
36+
import javax.swing.JPanel;
37+
import javax.swing.JSlider;
38+
import javax.swing.SwingConstants;
3239
import javax.swing.plaf.metal.DefaultMetalTheme;
3340
import javax.swing.plaf.metal.MetalLookAndFeel;
3441

35-
public class bug6742358 extends JApplet {
36-
public static void main(String[] args) {
37-
MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
38-
39-
JFrame frame = new JFrame();
40-
41-
frame.setContentPane(new TestPanel());
42-
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
43-
frame.pack();
44-
frame.setLocationRelativeTo(null);
42+
public class bug6742358 {
43+
private static final String INSTRUCTIONS = """
44+
Check that all sliders look good.""";
4545

46-
frame.setVisible(true);
47-
}
48-
49-
public void init() {
46+
public static void main(String[] args) throws Exception {
5047
MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
48+
PassFailJFrame.builder()
49+
.title("JSlider Instructions")
50+
.instructions(INSTRUCTIONS)
51+
.rows(5)
52+
.columns(40)
53+
.testUI(bug6742358::createAndShowUI)
54+
.build()
55+
.awaitAndCheck();
56+
}
5157

58+
public static JFrame createAndShowUI() {
59+
JFrame frame = new JFrame("Test Sliders");
5260
TestPanel panel = new TestPanel();
53-
54-
setContentPane(panel);
61+
frame.setSize(400, 300);
62+
frame.getContentPane().add(panel);
63+
return frame;
5564
}
5665

5766
private static class TestPanel extends JPanel {
@@ -62,30 +71,35 @@ private TestPanel() {
6271
pnVertical.setLayout(new BoxLayout(pnVertical, BoxLayout.Y_AXIS));
6372

6473
for (int i = 0; i < 8; i++) {
65-
pnVertical.add(createSlider(false, (i & 4) == 0, (i & 2) == 0, (i & 1) == 0));
74+
pnVertical.add(createSlider(false, (i & 4) == 0,
75+
(i & 2) == 0, (i & 1) == 0));
6676
}
6777

6878
JPanel pnHorizontal = new JPanel();
6979

7080
pnHorizontal.setLayout(new BoxLayout(pnHorizontal, BoxLayout.X_AXIS));
7181

7282
for (int i = 0; i < 8; i++) {
73-
pnHorizontal.add(createSlider(true, (i & 4) == 0, (i & 2) == 0, (i & 1) == 0));
83+
pnHorizontal.add(createSlider(true, (i & 4) == 0,
84+
(i & 2) == 0, (i & 1) == 0));
7485
}
7586

7687
add(pnHorizontal);
7788
add(pnVertical);
7889
}
7990
}
8091

81-
private static JSlider createSlider(boolean vertical, boolean enabled, boolean filled, boolean inverted) {
82-
JSlider result = new JSlider(vertical ? SwingConstants.VERTICAL : SwingConstants.HORIZONTAL, 0, 10, 5);
92+
private static JSlider createSlider(boolean vertical, boolean enabled,
93+
boolean filled, boolean inverted) {
94+
JSlider result = new JSlider(vertical ? SwingConstants.VERTICAL : SwingConstants.HORIZONTAL,
95+
0, 10, 5);
8396

8497
result.setEnabled(enabled);
8598
result.putClientProperty("JSlider.isFilled", filled);
8699
result.setInverted(inverted);
87-
result.setToolTipText("<html>vertical = " + vertical + "<br>enabled = " + enabled + "<br>filled = " + filled +
88-
"<br>inverted = " + inverted + "</html>");
100+
result.setToolTipText("<html>vertical = " + vertical + "<br>enabled = "
101+
+ enabled+ "<br>filled = " + filled
102+
+ "<br>inverted = " + inverted + "</html>");
89103

90104
return result;
91105
}

1 commit comments

Comments
 (1)

openjdk-notifier[bot] commented on Mar 19, 2024

@openjdk-notifier[bot]
Please sign in to comment.