Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/swing/JSlider/6794831/bug6794831.java
41153 views
1
/*
2
* Copyright (c) 2009, 2014, 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
* @key headful
27
* @bug 6794831
28
* @summary Infinite loop while painting ticks on Slider with maximum=MAX_INT
29
* @author Pavel Porvatov
30
@run main bug6794831
31
*/
32
33
import javax.swing.*;
34
import javax.swing.plaf.basic.BasicSliderUI;
35
import java.awt.image.BufferedImage;
36
import java.lang.reflect.InvocationTargetException;
37
import java.util.concurrent.CountDownLatch;
38
import java.util.concurrent.TimeUnit;
39
40
public class bug6794831 {
41
private final CountDownLatch countDownLatch = new CountDownLatch(1);
42
43
public static void main(String args[])
44
throws InterruptedException, InvocationTargetException {
45
new bug6794831().run();
46
}
47
48
private void run() throws InterruptedException, InvocationTargetException {
49
SwingUtilities.invokeAndWait(new Runnable() {
50
public void run() {
51
for (UIManager.LookAndFeelInfo lookAndFeelInfo : UIManager.getInstalledLookAndFeels()) {
52
try {
53
UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
54
} catch (Exception e) {
55
fail(e.getMessage());
56
}
57
58
BufferedImage image = new BufferedImage(300, 200, BufferedImage.TYPE_INT_ARGB);
59
60
// Test 1
61
JSlider slider = new JSlider(0, Integer.MAX_VALUE - 1, 0);
62
63
slider.setMajorTickSpacing((Integer.MAX_VALUE - 1) / 4);
64
slider.setPaintTicks(true);
65
66
((BasicSliderUI) slider.getUI()).paintTicks(image.getGraphics());
67
68
// Test 2
69
slider = new JSlider(0, Integer.MAX_VALUE - 1, 0);
70
71
slider.setMinorTickSpacing((Integer.MAX_VALUE - 1) / 4);
72
slider.setPaintTicks(true);
73
74
((BasicSliderUI) slider.getUI()).paintTicks(image.getGraphics());
75
76
// Test 3
77
slider = new JSlider(0, Integer.MAX_VALUE - 1, 0);
78
79
slider.setOrientation(JSlider.VERTICAL);
80
slider.setMajorTickSpacing((Integer.MAX_VALUE - 1) / 4);
81
slider.setPaintTicks(true);
82
83
((BasicSliderUI) slider.getUI()).paintTicks(image.getGraphics());
84
85
// Test 4
86
slider = new JSlider(0, Integer.MAX_VALUE - 1, 0);
87
88
slider.setOrientation(JSlider.VERTICAL);
89
slider.setMinorTickSpacing((Integer.MAX_VALUE - 1) / 4);
90
slider.setPaintTicks(true);
91
92
((BasicSliderUI) slider.getUI()).paintTicks(image.getGraphics());
93
94
countDownLatch.countDown();
95
}
96
}
97
});
98
99
if (countDownLatch.await(3000, TimeUnit.MILLISECONDS)) {
100
System.out.println("bug6794831 passed");
101
} else {
102
fail("bug6794831 failed");
103
}
104
}
105
106
private static void fail(String msg) {
107
throw new RuntimeException(msg);
108
}
109
}
110
111