Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/javax/swing/JFileChooser/6489130/bug6489130.java
41154 views
1
/*
2
* Copyright (c) 2009, 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
* @key headful
26
* @bug 6489130
27
* @summary FileChooserDemo hung by keeping pressing Enter key
28
* @author Pavel Porvatov
29
@run main bug6489130
30
*/
31
32
import javax.swing.*;
33
import java.awt.*;
34
import java.awt.event.ActionEvent;
35
import java.awt.event.ActionListener;
36
import java.util.concurrent.CountDownLatch;
37
import java.util.concurrent.TimeUnit;
38
39
public class bug6489130 {
40
private final JFileChooser chooser = new JFileChooser();
41
42
private static final CountDownLatch MUX = new CountDownLatch(1);
43
44
private final Timer timer = new Timer(1000, new ActionListener() {
45
public void actionPerformed(ActionEvent e) {
46
switch (state) {
47
case 0:
48
case 1: {
49
SwingUtilities.invokeLater(new Runnable() {
50
public void run() {
51
chooser.showOpenDialog(null);
52
}
53
});
54
55
break;
56
}
57
58
case 2:
59
case 3: {
60
Window[] windows = Frame.getWindows();
61
62
if (windows.length > 0) {
63
windows[0].dispose();
64
}
65
66
break;
67
}
68
69
case 4: {
70
MUX.countDown();
71
72
break;
73
}
74
}
75
76
state++;
77
}
78
});
79
80
private int state = 0;
81
82
public static void main(String[] args) throws InterruptedException {
83
SwingUtilities.invokeLater(new Runnable() {
84
public void run() {
85
new bug6489130().run();
86
}
87
});
88
89
if (!MUX.await(10, TimeUnit.SECONDS)) {
90
throw new RuntimeException("Timeout");
91
}
92
}
93
94
private void run() {
95
timer.start();
96
}
97
}
98
99