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/JViewport/7107099/bug7107099.java
38867 views
1
/*
2
* Copyright (c) 2012, 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
/* @test
25
@bug 7107099
26
@summary JScrollBar does not show up even if there are enough lebgth of textstring in textField
27
@author Pavel Porvatov
28
*/
29
30
import javax.swing.*;
31
import java.awt.*;
32
33
public class bug7107099 {
34
private static JFrame frame;
35
private static JTextArea textarea;
36
private static JScrollPane scrollPane;
37
38
private static int value;
39
private static int min;
40
private static int max;
41
private static int extent;
42
43
public static void main(String[] args) throws Exception {
44
45
java.awt.Robot robot = new java.awt.Robot();
46
47
SwingUtilities.invokeAndWait(new Runnable() {
48
@Override
49
public void run() {
50
textarea = new JTextArea("before###1###\nbefore###2###\nbefore###3###\nbefore###4###\nbefore###5###\n");
51
52
scrollPane = new JScrollPane(textarea);
53
scrollPane.setPreferredSize(new Dimension(100, 50));
54
55
frame = new JFrame();
56
frame.setLayout(new BorderLayout());
57
frame.setSize(200, 200);
58
frame.add(scrollPane, BorderLayout.SOUTH);
59
frame.setVisible(true);
60
}
61
});
62
63
robot.waitForIdle();
64
65
SwingUtilities.invokeAndWait(new Runnable() {
66
@Override
67
public void run() {
68
BoundedRangeModel model = scrollPane.getVerticalScrollBar().getModel();
69
70
value = model.getValue();
71
min = model.getMinimum();
72
max = model.getMaximum();
73
extent = model.getExtent();
74
75
// Do tricky manipulation for testing purpose
76
textarea.setText(null);
77
scrollPane.setViewportView(textarea);
78
textarea.setText("after###1###\nafter###1###\nafter###1###\nafter###1###\nafter###1###\n");
79
textarea.setCaretPosition(0);
80
}
81
});
82
83
robot.waitForIdle();
84
85
SwingUtilities.invokeAndWait(new Runnable() {
86
@Override
87
public void run() {
88
BoundedRangeModel model = scrollPane.getVerticalScrollBar().getModel();
89
90
if (value != model.getValue() ||
91
min != model.getMinimum() ||
92
max != model.getMaximum() ||
93
extent != model.getExtent()) {
94
throw new RuntimeException("Test bug7107099 failed");
95
}
96
97
System.out.println("Test bug7107099 passed");
98
99
frame.dispose();
100
}
101
});
102
}
103
}
104
105