Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/javax/swing/JScrollBar/7163696/Test7163696.java
38918 views
1
/*
2
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
24
/*
25
* @test
26
* @bug 7163696
27
* @summary Tests that JScrollBar scrolls to the left
28
* @author Sergey Malenkov
29
*/
30
31
import java.awt.Dimension;
32
import java.awt.Point;
33
import java.awt.Robot;
34
import java.awt.event.InputEvent;
35
36
import javax.swing.JFrame;
37
import javax.swing.JScrollBar;
38
import javax.swing.SwingUtilities;
39
import javax.swing.UIManager;
40
import javax.swing.UIManager.LookAndFeelInfo;
41
42
public class Test7163696 implements Runnable {
43
44
private static final boolean AUTO = null != System.getProperty("test.src", null);
45
46
public static void main(String[] args) throws Exception {
47
new Test7163696().test();
48
}
49
50
private JScrollBar bar;
51
52
private void test() throws Exception {
53
Robot robot = new Robot();
54
for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
55
UIManager.setLookAndFeel(info.getClassName());
56
57
SwingUtilities.invokeAndWait(this);
58
robot.waitForIdle(); // after creation
59
Thread.sleep(1000);
60
61
Point point = this.bar.getLocation();
62
SwingUtilities.convertPointToScreen(point, this.bar);
63
point.x += this.bar.getWidth() >> 2;
64
point.y += this.bar.getHeight() >> 1;
65
robot.mouseMove(point.x, point.y);
66
robot.mousePress(InputEvent.BUTTON1_MASK);
67
robot.mouseRelease(InputEvent.BUTTON1_MASK);
68
69
robot.waitForIdle(); // before validation
70
Thread.sleep(1000);
71
SwingUtilities.invokeAndWait(this);
72
73
if (this.bar != null) {
74
this.bar = null; // allows to reuse the instance
75
if (AUTO) { // error reporting only for automatic testing
76
throw new Error("TEST FAILED");
77
}
78
}
79
}
80
}
81
82
public void run() {
83
if (this.bar == null) {
84
this.bar = new JScrollBar(JScrollBar.HORIZONTAL, 50, 10, 0, 100);
85
this.bar.setPreferredSize(new Dimension(400, 20));
86
87
JFrame frame = new JFrame();
88
frame.add(this.bar);
89
frame.pack();
90
frame.setVisible(true);
91
}
92
else if (40 != this.bar.getValue()) {
93
System.out.println("name = " + UIManager.getLookAndFeel().getName());
94
System.out.println("value = " + this.bar.getValue());
95
}
96
else {
97
SwingUtilities.getWindowAncestor(this.bar).dispose();
98
this.bar = null;
99
}
100
}
101
}
102
103