Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/swing/JSpinner/5012888/bug5012888.java
41153 views
1
/*
2
* Copyright (c) 2012, 2016, 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 1.0 04/04/23
26
* @key headful
27
* @bug 5012888
28
* @summary REGRESSION: Click & hold on arrow of JSpinner only transfers focus
29
* @author Konstantin Eremin
30
* @run main bug5012888
31
*/
32
33
import javax.swing.*;
34
import javax.swing.event.*;
35
import java.awt.*;
36
import java.awt.event.*;
37
38
public class bug5012888 extends JFrame {
39
JSpinner spinner1, spinner2;
40
public bug5012888() {
41
spinner1 = new JSpinner(new SpinnerNumberModel(0, -1000, 1000, 1));
42
spinner2 = new JSpinner(new SpinnerNumberModel(1, -1000, 1000, 1));
43
Container pane = getContentPane();
44
pane.setLayout(new BorderLayout());
45
pane.add(spinner1, BorderLayout.NORTH);
46
pane.add(spinner2, BorderLayout.SOUTH);
47
}
48
public void doTest() throws Exception {
49
Robot robot = new Robot();
50
robot.waitForIdle();
51
Point p = spinner2.getLocationOnScreen();
52
Rectangle rect = spinner2.getBounds();
53
robot.mouseMove(p.x+rect.width-5, p.y+5);
54
robot.mousePress(InputEvent.BUTTON1_MASK);
55
Thread.sleep(1000);
56
robot.mouseRelease(InputEvent.BUTTON1_MASK);
57
if ( ((Integer) spinner2.getValue()).intValue() == 1 ) {
58
throw new Error("Spinner value should be more than 1");
59
}
60
}
61
public static void main(String[] argv) throws Exception {
62
bug5012888 b = new bug5012888();
63
b.setBounds(0, 0, 100, 100);
64
b.setVisible(true);
65
b.doTest();
66
}
67
}
68
69