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/4865918/bug4865918.java
38918 views
1
/*
2
* Copyright (c) 2011, 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 4865918
27
* @summary REGRESSION:JCK1.4a-runtime api/javax_swing/interactive/JScrollBarTests.html#JScrollBar
28
* @author Andrey Pikalev
29
* @run main bug4865918
30
*/
31
32
import javax.swing.*;
33
import java.awt.*;
34
import java.awt.event.*;
35
import java.util.*;
36
37
public class bug4865918 {
38
39
private static TestScrollBar sbar;
40
41
public static void main(String[] argv) throws Exception {
42
43
Robot robot = new Robot();
44
SwingUtilities.invokeAndWait(new Runnable() {
45
46
public void run() {
47
createAndShowGUI();
48
}
49
});
50
51
robot.waitForIdle();
52
53
SwingUtilities.invokeAndWait(new Runnable() {
54
55
@Override
56
public void run() {
57
sbar.pressMouse();
58
}
59
});
60
61
robot.waitForIdle();
62
63
int value = getValue();
64
65
if (value != 9) {
66
throw new Error("The scrollbar block increment is incorect");
67
}
68
}
69
70
private static int getValue() throws Exception {
71
final int[] result = new int[1];
72
73
SwingUtilities.invokeAndWait(new Runnable() {
74
@Override
75
public void run() {
76
result[0] = sbar.getValue();
77
}
78
});
79
80
return result[0];
81
}
82
83
private static void createAndShowGUI() {
84
JFrame frame = new JFrame("bug4865918");
85
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
86
87
sbar = new TestScrollBar(JScrollBar.HORIZONTAL, -1, 10, -100, 100);
88
sbar.setPreferredSize(new Dimension(200, 20));
89
sbar.setBlockIncrement(10);
90
91
frame.getContentPane().add(sbar);
92
frame.pack();
93
frame.setVisible(true);
94
95
}
96
97
static class TestScrollBar extends JScrollBar {
98
99
public TestScrollBar(int orientation, int value, int extent,
100
int min, int max) {
101
super(orientation, value, extent, min, max);
102
103
}
104
105
public void pressMouse() {
106
MouseEvent me = new MouseEvent(sbar,
107
MouseEvent.MOUSE_PRESSED,
108
(new Date()).getTime(),
109
MouseEvent.BUTTON1_MASK,
110
3 * getWidth() / 4, getHeight() / 2,
111
1, true);
112
processMouseEvent(me);
113
}
114
}
115
}
116
117