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/JTextArea/6940863/bug6940863.java
38854 views
1
/*
2
* Copyright (c) 2010, 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 6940863
26
* @summary Textarea within scrollpane shows vertical scrollbar
27
* @author Pavel Porvatov
28
* @run main bug6940863
29
*/
30
31
import sun.awt.OSInfo;
32
33
import javax.swing.*;
34
import java.awt.*;
35
import java.awt.event.ActionEvent;
36
import java.awt.event.ActionListener;
37
38
public class bug6940863 {
39
private static JFrame frame;
40
41
private static JScrollPane scrollPane;
42
43
private static final Timer timer = new Timer(1000, new ActionListener() {
44
public void actionPerformed(ActionEvent e) {
45
boolean failed = scrollPane.getVerticalScrollBar().isShowing() ||
46
scrollPane.getHorizontalScrollBar().isShowing();
47
48
frame.dispose();
49
50
if (failed) {
51
throw new RuntimeException("The test failed");
52
}
53
}
54
});
55
56
public static void main(String[] args) throws Exception {
57
if (OSInfo.getOSType() != OSInfo.OSType.WINDOWS) {
58
System.out.println("The test is suitable only for Windows OS. Skipped");
59
return;
60
}
61
62
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
63
64
SwingUtilities.invokeAndWait(new Runnable() {
65
public void run() {
66
JTextArea textArea = new JTextArea();
67
68
textArea.setLineWrap(true);
69
textArea.setWrapStyleWord(true);
70
71
scrollPane = new JScrollPane(textArea);
72
73
scrollPane.setMinimumSize(new Dimension(200, 100));
74
scrollPane.setPreferredSize(new Dimension(300, 150));
75
76
frame = new JFrame("Vertical scrollbar shown without text");
77
78
frame.setContentPane(scrollPane);
79
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
80
frame.pack();
81
frame.setVisible(true);
82
83
timer.setRepeats(false);
84
timer.start();
85
}
86
});
87
}
88
}
89
90