Skip to content

Commit 56248f8

Browse files
committed
8327756: Convert javax/swing/JSlider/4987336/bug4987336.java applet to main
Backport-of: 06f4b7f54da03e57abfe8958e4354c1ecb7e3039
1 parent 9d4f3b7 commit 56248f8

File tree

2 files changed

+49
-46
lines changed

2 files changed

+49
-46
lines changed

test/jdk/javax/swing/JSlider/4987336/bug4987336.html

Lines changed: 0 additions & 32 deletions
This file was deleted.

test/jdk/javax/swing/JSlider/4987336/bug4987336.java

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
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.
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,25 +21,58 @@
2121
* questions.
2222
*/
2323

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
2931
*/
30-
31-
import javax.swing.*;
32-
import javax.swing.border.TitledBorder;
3332
import java.awt.event.ActionEvent;
3433
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;
3548
import java.util.Hashtable;
3649

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+
3857
private static final String IMAGE_RES = "box.gif";
3958

4059
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+
}
4173

42-
public void init() {
74+
private static JFrame createTestUI() {
75+
frame = new JFrame("bug4987336");
4376
JPanel pnLafs = new JPanel();
4477
pnLafs.setLayout(new BoxLayout(pnLafs, BoxLayout.Y_AXIS));
4578

@@ -64,7 +97,9 @@ public void init() {
6497
pnContent.add(createSlider(true, ANIM_IMAGE_RES, null, IMAGE_RES, IMAGE_RES));
6598
pnContent.add(createSlider(false, ANIM_IMAGE_RES, null, IMAGE_RES, IMAGE_RES));
6699

67-
getContentPane().add(new JScrollPane(pnContent));
100+
frame.getContentPane().add(new JScrollPane(pnContent));
101+
frame.pack();
102+
return frame;
68103
}
69104

70105
private static JSlider createSlider(boolean enabled,
@@ -99,7 +134,7 @@ private static JLabel createLabel(String enabledImage, String disabledImage) {
99134
return result;
100135
}
101136

102-
private class LafRadioButton extends JRadioButton {
137+
private static class LafRadioButton extends JRadioButton {
103138
public LafRadioButton(final UIManager.LookAndFeelInfo lafInfo) {
104139
super(lafInfo.getName(), lafInfo.getName().equals(UIManager.getLookAndFeel().getName()));
105140

@@ -108,7 +143,7 @@ public void actionPerformed(ActionEvent e) {
108143
try {
109144
UIManager.setLookAndFeel(lafInfo.getClassName());
110145

111-
SwingUtilities.updateComponentTreeUI(bug4987336.this);
146+
SwingUtilities.updateComponentTreeUI(frame);
112147
} catch (Exception ex) {
113148
// Ignore such errors
114149
System.out.println("Cannot set LAF " + lafInfo.getName());

0 commit comments

Comments
 (0)