Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/awt/Mouse/TitleBarDoubleClick/TitleBarDoubleClick.java
47490 views
1
/*
2
* Copyright (c) 2002, 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 4664415
27
@summary REGRESSION: double click jframe titlebar generating mouse events in panel
28
@author Andrei Dmitriev: area=awt.mouse
29
@run applet TitleBarDoubleClick.html
30
*/
31
import java.applet.Applet;
32
import java.awt.*;
33
import java.awt.event.*;
34
import test.java.awt.regtesthelpers.Util;
35
36
public class TitleBarDoubleClick extends Applet implements MouseListener,
37
WindowListener
38
{
39
//Declare things used in the test, like buttons and labels here
40
private final static Rectangle BOUNDS = new Rectangle(300, 300, 300, 300);
41
private final static int TITLE_BAR_OFFSET = 10;
42
43
Frame frame;
44
Robot robot;
45
46
public void init()
47
{
48
this.setLayout (new BorderLayout ());
49
50
}//End init()
51
52
public void start ()
53
{
54
//Get things going. Request focus, set size, et cetera
55
setSize (200,200);
56
setVisible(true);
57
validate();
58
59
//What would normally go into main() will probably go here.
60
//Use System.out.println for diagnostic messages that you want
61
//to read after the test is done.
62
//Use Sysout.println for messages you want the tester to read.
63
64
robot = Util.createRobot();
65
robot.setAutoDelay(100);
66
robot.mouseMove(BOUNDS.x + (BOUNDS.width / 2),
67
BOUNDS.y + (BOUNDS.height/ 2));
68
69
frame = new Frame("TitleBarDoubleClick");
70
frame.setBounds(BOUNDS);
71
frame.addMouseListener(this);
72
frame.addWindowListener(this);
73
frame.setVisible(true);
74
Util.waitForIdle(robot);
75
}// start()
76
77
// Move the mouse into the title bar and double click to maximize the
78
// Frame
79
static boolean hasRun = false;
80
81
private void doTest() {
82
if (hasRun) return;
83
hasRun = true;
84
85
System.out.println("doing test");
86
robot.mouseMove(BOUNDS.x + (BOUNDS.width / 2),
87
BOUNDS.y + TITLE_BAR_OFFSET);
88
robot.delay(50);
89
// Util.waitForIdle(robot) seem always hangs here.
90
// Need to use it instead robot.delay() when the bug become fixed.
91
System.out.println("1st press: currentTimeMillis: " + System.currentTimeMillis());
92
robot.mousePress(InputEvent.BUTTON1_MASK);
93
robot.delay(50);
94
System.out.println("1st release: currentTimeMillis: " + System.currentTimeMillis());
95
robot.mouseRelease(InputEvent.BUTTON1_MASK);
96
robot.delay(50);
97
System.out.println("2nd press: currentTimeMillis: " + System.currentTimeMillis());
98
robot.mousePress(InputEvent.BUTTON1_MASK);
99
robot.delay(50);
100
System.out.println("2nd release: currentTimeMillis: " + System.currentTimeMillis());
101
robot.mouseRelease(InputEvent.BUTTON1_MASK);
102
System.out.println("done: currentTimeMillis: " + System.currentTimeMillis());
103
}
104
105
private void fail() {
106
throw new AWTError("Test failed");
107
}
108
109
public void mouseEntered(MouseEvent e) {}
110
public void mouseExited(MouseEvent e) {}
111
public void mousePressed(MouseEvent e) {fail();}
112
public void mouseReleased(MouseEvent e) {fail();}
113
public void mouseClicked(MouseEvent e) {fail();}
114
115
public void windowActivated(WindowEvent e) {doTest();}
116
public void windowClosed(WindowEvent e) {}
117
public void windowClosing(WindowEvent e) {}
118
public void windowDeactivated(WindowEvent e) {}
119
public void windowDeiconified(WindowEvent e) {}
120
public void windowIconified(WindowEvent e) {}
121
public void windowOpened(WindowEvent e) {}
122
123
}// class TitleBarDoubleClick
124
125