author | sangheki |
Thu, 24 Mar 2016 23:07:06 -0700 | |
changeset 37194 | 96cc74bd293b |
parent 26750 | d0d6c64a2e2b |
permissions | -rw-r--r-- |
23240
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
1 |
/* |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
2 |
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
4 |
* |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
8 |
* |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
13 |
* accompanied this code). |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
14 |
* |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
18 |
* |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
21 |
* questions. |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
22 |
*/ |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
23 |
|
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
24 |
|
26750
d0d6c64a2e2b
8058726: Update regtests using sun.awt.OSInfo, part 1
yan
parents:
23240
diff
changeset
|
25 |
import jdk.testlibrary.OSInfo; |
23240
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
26 |
import test.java.awt.regtesthelpers.Sysout; |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
27 |
|
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
28 |
import java.applet.Applet; |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
29 |
import java.awt.Button; |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
30 |
import java.awt.FileDialog; |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
31 |
import java.awt.Frame; |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
32 |
import java.awt.GridLayout; |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
33 |
import java.awt.event.ActionEvent; |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
34 |
import java.awt.event.ActionListener; |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
35 |
|
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
36 |
public class FileDialogForPackages extends Applet implements ActionListener { |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
37 |
private static final String APPLICATIONS_FOLDER = "/Applications"; |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
38 |
|
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
39 |
private volatile Button showBtn; |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
40 |
private volatile FileDialog fd; |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
41 |
|
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
42 |
@Override |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
43 |
public void init() { |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
44 |
if (OSInfo.getOSType() != OSInfo.OSType.MACOSX) { |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
45 |
Sysout.createDialogWithInstructions(new String[]{ |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
46 |
"Press PASS, this test is for MacOS X only."}); |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
47 |
return; |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
48 |
} |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
49 |
|
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
50 |
System.setProperty("apple.awt.use-file-dialog-packages", "true"); |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
51 |
|
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
52 |
setLayout(new GridLayout(1, 1)); |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
53 |
|
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
54 |
fd = new FileDialog(new Frame(), "Open"); |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
55 |
fd.setDirectory(APPLICATIONS_FOLDER); |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
56 |
|
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
57 |
showBtn = new Button("Show File Dialog"); |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
58 |
showBtn.addActionListener(this); |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
59 |
add(showBtn); |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
60 |
String[] instructions = { |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
61 |
"1) Click on 'Show File Dialog' button. A file dialog will come up.", |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
62 |
"2) Navigate to the Applications folder if not already there", |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
63 |
"3) Check that the application bundles can be selected and can not be navigated", |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
64 |
"4) If it's true then the test passed, otherwise it failed."}; |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
65 |
Sysout.createDialogWithInstructions(instructions); |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
66 |
} |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
67 |
|
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
68 |
@Override |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
69 |
public void start() { |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
70 |
setSize(200, 200); |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
71 |
show(); |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
72 |
} |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
73 |
|
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
74 |
@Override |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
75 |
public void actionPerformed(ActionEvent e) { |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
76 |
if (e.getSource() == showBtn) { |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
77 |
fd.setVisible(true); |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
78 |
String output = fd.getFile(); |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
79 |
if (output != null) { |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
80 |
Sysout.println(output + " is selected"); |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
81 |
} |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
82 |
} |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
83 |
} |
1125cbc3f4b7
8026869: [macosx] Support apple.awt.use-file-dialog-packages property
pchelko
parents:
diff
changeset
|
84 |
} |