Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/awt/FileDialog/FileDialogForPackages/FileDialogForPackages.java
41153 views
1
/*
2
* Copyright (c) 2013, 2018, 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
import jdk.test.lib.Platform;
26
import test.java.awt.regtesthelpers.Sysout;
27
28
import java.applet.Applet;
29
import java.awt.Button;
30
import java.awt.FileDialog;
31
import java.awt.Frame;
32
import java.awt.GridLayout;
33
import java.awt.event.ActionEvent;
34
import java.awt.event.ActionListener;
35
36
public class FileDialogForPackages extends Applet implements ActionListener {
37
private static final String APPLICATIONS_FOLDER = "/Applications";
38
39
private volatile Button showBtn;
40
private volatile FileDialog fd;
41
42
@Override
43
public void init() {
44
if (!Platform.isOSX()) {
45
Sysout.createDialogWithInstructions(new String[]{
46
"Press PASS, this test is for MacOS X only."});
47
return;
48
}
49
50
System.setProperty("apple.awt.use-file-dialog-packages", "true");
51
52
setLayout(new GridLayout(1, 1));
53
54
fd = new FileDialog(new Frame(), "Open");
55
fd.setDirectory(APPLICATIONS_FOLDER);
56
57
showBtn = new Button("Show File Dialog");
58
showBtn.addActionListener(this);
59
add(showBtn);
60
String[] instructions = {
61
"1) Click on 'Show File Dialog' button. A file dialog will come up.",
62
"2) Navigate to the Applications folder if not already there",
63
"3) Check that the application bundles can be selected and can not be navigated",
64
"4) If it's true then the test passed, otherwise it failed."};
65
Sysout.createDialogWithInstructions(instructions);
66
}
67
68
@Override
69
public void start() {
70
setSize(200, 200);
71
show();
72
}
73
74
@Override
75
public void actionPerformed(ActionEvent e) {
76
if (e.getSource() == showBtn) {
77
fd.setVisible(true);
78
String output = fd.getFile();
79
if (output != null) {
80
Sysout.println(output + " is selected");
81
}
82
}
83
}
84
}
85
86