Skip to content

8328244: Convert javax/swing/JSlider/6742358/bug6742358.java applet test to main #3804

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions test/jdk/javax/swing/JSlider/6742358/bug6742358.html

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -21,37 +21,46 @@
* questions.
*/

/* @test
/*
* @test
* @bug 6742358
* @summary MetalSliderUI paint wrong vertical disabled filled JSlider for DefaultMetalTheme
* @author Pavel Porvatov
* @run applet/manual=done bug6742358.html
* @summary Verifies that painting a vertical disabled filled JSlider, the
* track will be painted correctly for DefaultMetalTheme.
* @library /java/awt/regtesthelpers
* @build PassFailJFrame
* @run main/manual bug6742358
*/

import javax.swing.*;
import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JSlider;
import javax.swing.SwingConstants;
import javax.swing.plaf.metal.DefaultMetalTheme;
import javax.swing.plaf.metal.MetalLookAndFeel;

public class bug6742358 extends JApplet {
public static void main(String[] args) {
MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());

JFrame frame = new JFrame();

frame.setContentPane(new TestPanel());
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo(null);
public class bug6742358 {
private static final String INSTRUCTIONS = """
Check that all sliders look good.""";

frame.setVisible(true);
}

public void init() {
public static void main(String[] args) throws Exception {
MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
PassFailJFrame.builder()
.title("JSlider Instructions")
.instructions(INSTRUCTIONS)
.rows(5)
.columns(40)
.testUI(bug6742358::createAndShowUI)
.build()
.awaitAndCheck();
}

public static JFrame createAndShowUI() {
JFrame frame = new JFrame("Test Sliders");
TestPanel panel = new TestPanel();

setContentPane(panel);
frame.setSize(400, 300);
frame.getContentPane().add(panel);
return frame;
}

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

for (int i = 0; i < 8; i++) {
pnVertical.add(createSlider(false, (i & 4) == 0, (i & 2) == 0, (i & 1) == 0));
pnVertical.add(createSlider(false, (i & 4) == 0,
(i & 2) == 0, (i & 1) == 0));
}

JPanel pnHorizontal = new JPanel();

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

for (int i = 0; i < 8; i++) {
pnHorizontal.add(createSlider(true, (i & 4) == 0, (i & 2) == 0, (i & 1) == 0));
pnHorizontal.add(createSlider(true, (i & 4) == 0,
(i & 2) == 0, (i & 1) == 0));
}

add(pnHorizontal);
add(pnVertical);
}
}

private static JSlider createSlider(boolean vertical, boolean enabled, boolean filled, boolean inverted) {
JSlider result = new JSlider(vertical ? SwingConstants.VERTICAL : SwingConstants.HORIZONTAL, 0, 10, 5);
private static JSlider createSlider(boolean vertical, boolean enabled,
boolean filled, boolean inverted) {
JSlider result = new JSlider(vertical ? SwingConstants.VERTICAL : SwingConstants.HORIZONTAL,
0, 10, 5);

result.setEnabled(enabled);
result.putClientProperty("JSlider.isFilled", filled);
result.setInverted(inverted);
result.setToolTipText("<html>vertical = " + vertical + "<br>enabled = " + enabled + "<br>filled = " + filled +
"<br>inverted = " + inverted + "</html>");
result.setToolTipText("<html>vertical = " + vertical + "<br>enabled = "
+ enabled+ "<br>filled = " + filled
+ "<br>inverted = " + inverted + "</html>");

return result;
}
Expand Down