|
1 | 1 | /* |
2 | | - * Copyright (c) 2008, 2017, 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 |
| 24 | +/* |
| 25 | + * @test |
25 | 26 | * @bug 6524424 |
26 | 27 | * @requires (os.family == "windows") |
27 | | - * @summary JSlider Clicking In Tracks Behavior Inconsistent For Different Tick Spacings |
28 | | - * @author Pavel Porvatov |
| 28 | + * @summary JSlider clicking in tracks behavior inconsistent for different tick spacings |
29 | 29 | * @modules java.desktop/com.sun.java.swing.plaf.windows |
30 | | - * @run applet/manual=done bug6524424.html |
| 30 | + * @library /java/awt/regtesthelpers |
| 31 | + * @build PassFailJFrame |
| 32 | + * @run main/manual bug6524424 |
31 | 33 | */ |
32 | 34 |
|
33 | | -import java.awt.*; |
34 | | -import javax.swing.*; |
| 35 | +import java.awt.Component; |
| 36 | +import java.awt.GridBagConstraints; |
| 37 | +import java.awt.GridBagLayout; |
| 38 | +import java.awt.Insets; |
| 39 | +import javax.swing.JFrame; |
| 40 | +import javax.swing.JPanel; |
| 41 | +import javax.swing.JSlider; |
| 42 | +import javax.swing.SwingUtilities; |
| 43 | +import javax.swing.UIManager; |
| 44 | +import javax.swing.UnsupportedLookAndFeelException; |
35 | 45 |
|
36 | 46 | import com.sun.java.swing.plaf.windows.WindowsLookAndFeel; |
37 | 47 |
|
38 | | -public class bug6524424 extends JApplet { |
39 | | - public static void main(String[] args) { |
| 48 | +public class bug6524424 { |
| 49 | + private static final String INSTRUCTIONS = """ |
| 50 | + 1. Select a slider (do the next steps for every slider) |
| 51 | + 2. Check that the next keyboard buttons work correctly: |
| 52 | + Up, Down, Left, Right, Page Up, Page Down |
| 53 | + 3. Press left mouse button on a free space of the slider |
| 54 | + check if thumb moves correctly |
| 55 | + press Pass else press Fail."""; |
| 56 | + |
| 57 | + public static void main(String[] args) throws Exception { |
| 58 | + PassFailJFrame.builder() |
| 59 | + .title("Slider Behavior Instructions") |
| 60 | + .instructions(INSTRUCTIONS) |
| 61 | + .rows(7) |
| 62 | + .columns(30) |
| 63 | + .testUI(bug6524424::createTestUI) |
| 64 | + .build() |
| 65 | + .awaitAndCheck(); |
| 66 | + } |
| 67 | + |
| 68 | + private static JFrame createTestUI() { |
40 | 69 | try { |
41 | 70 | UIManager.setLookAndFeel(new WindowsLookAndFeel()); |
42 | | - } catch (UnsupportedLookAndFeelException e) { |
43 | | - e.printStackTrace(); |
44 | | - |
45 | | - return; |
| 71 | + } catch (UnsupportedLookAndFeelException ex) { |
| 72 | + PassFailJFrame.forceFail(ex.toString()); |
| 73 | + return null; |
46 | 74 | } |
47 | 75 |
|
48 | 76 | TestPanel panel = new TestPanel(); |
49 | 77 |
|
50 | | - JFrame frame = new JFrame(); |
| 78 | + JFrame frame = new JFrame("bug6524424"); |
51 | 79 |
|
52 | 80 | frame.setContentPane(panel); |
53 | | - frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); |
54 | 81 | frame.pack(); |
55 | | - frame.setLocationRelativeTo(null); |
56 | | - |
57 | | - frame.setVisible(true); |
58 | | - } |
59 | | - |
60 | | - public void init() { |
61 | | - TestPanel panel = new TestPanel(); |
62 | | - |
63 | | - setContentPane(panel); |
| 82 | + return frame; |
64 | 83 | } |
65 | 84 |
|
66 | 85 | private static class TestPanel extends JPanel { |
|
0 commit comments