author | sangheki |
Thu, 24 Mar 2016 23:07:06 -0700 | |
changeset 37194 | 96cc74bd293b |
parent 31434 | 3b61ff08431b |
permissions | -rw-r--r-- |
31434
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
1 |
/* |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
2 |
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
4 |
* |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
8 |
* |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
13 |
* accompanied this code). |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
14 |
* |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
18 |
* |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
21 |
* questions. |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
22 |
*/ |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
23 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
24 |
/* |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
25 |
test |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
26 |
@bug 4974135 |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
27 |
@summary FileDialog should open current directory by default. |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
28 |
@author tav@sparc.spb.su area=awt.filedialog |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
29 |
@run applet/manual=yesno FileDialogOpenDirTest.html |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
30 |
*/ |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
31 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
32 |
import java.awt.*; |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
33 |
import java.awt.event.*; |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
34 |
import java.applet.*; |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
35 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
36 |
public class FileDialogOpenDirTest extends Applet { |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
37 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
38 |
public static void main(String[] args) { |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
39 |
Applet a = new FileDialogOpenDirTest(); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
40 |
a.init(); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
41 |
a.start(); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
42 |
} |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
43 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
44 |
public void init() |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
45 |
{ |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
46 |
System.setProperty("sun.awt.disableGtkFileDialogs","true"); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
47 |
//Create instructions for the user here, as well as set up |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
48 |
// the environment -- set the layout manager, add buttons, |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
49 |
// etc. |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
50 |
this.setLayout (new BorderLayout ()); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
51 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
52 |
String curdir = System.getProperty("user.dir"); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
53 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
54 |
String[] instructions1 = |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
55 |
{ |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
56 |
"After test started you will see 'Test Frame' with a button inside.", |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
57 |
"Click the button to open FileDialog.", |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
58 |
"Verify that the directory opened is current directory, that is:", |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
59 |
curdir, |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
60 |
"If so press PASSED, otherwise FAILED." |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
61 |
}; |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
62 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
63 |
String[] instructions2 = |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
64 |
{ |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
65 |
"The test is not applicable for current platform. Press PASSED." |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
66 |
}; |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
67 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
68 |
Sysout.createDialogWithInstructions(Toolkit.getDefaultToolkit().getClass().getName(). |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
69 |
equals("sun.awt.X11.XToolkit") ? |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
70 |
instructions1 : instructions2); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
71 |
} |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
72 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
73 |
public void start() { |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
74 |
Frame frame = new Frame("Test Frame"); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
75 |
Button open = new Button("Open File Dialog"); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
76 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
77 |
open.addActionListener(new ActionListener() { |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
78 |
public void actionPerformed(ActionEvent e) { |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
79 |
new FileDialog(new Frame()).show(); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
80 |
} |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
81 |
}); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
82 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
83 |
frame.setLayout(new FlowLayout()); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
84 |
frame.add(open); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
85 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
86 |
int x = 0; |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
87 |
int y = 0; |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
88 |
Component dlg = null; |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
89 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
90 |
if ((dlg = Sysout.getDialog()) != null) { |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
91 |
x = dlg.getBounds().x + dlg.getBounds().width; |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
92 |
y = dlg.getBounds().y; |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
93 |
} |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
94 |
frame.setBounds(x, y, 150, 70); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
95 |
frame.setVisible(true); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
96 |
} |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
97 |
} |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
98 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
99 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
100 |
/**************************************************** |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
101 |
Standard Test Machinery |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
102 |
DO NOT modify anything below -- it's a standard |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
103 |
chunk of code whose purpose is to make user |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
104 |
interaction uniform, and thereby make it simpler |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
105 |
to read and understand someone else's test. |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
106 |
****************************************************/ |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
107 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
108 |
/** |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
109 |
This is part of the standard test machinery. |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
110 |
It creates a dialog (with the instructions), and is the interface |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
111 |
for sending text messages to the user. |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
112 |
To print the instructions, send an array of strings to Sysout.createDialog |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
113 |
WithInstructions method. Put one line of instructions per array entry. |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
114 |
To display a message for the tester to see, simply call Sysout.println |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
115 |
with the string to be displayed. |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
116 |
This mimics System.out.println but works within the test harness as well |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
117 |
as standalone. |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
118 |
*/ |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
119 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
120 |
class Sysout |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
121 |
{ |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
122 |
private static TestDialog dialog; |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
123 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
124 |
public static void createDialogWithInstructions( String[] instructions ) |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
125 |
{ |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
126 |
dialog = new TestDialog( new Frame(), "Instructions" ); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
127 |
dialog.printInstructions( instructions ); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
128 |
dialog.setVisible(true); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
129 |
println( "Any messages for the tester will display here." ); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
130 |
} |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
131 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
132 |
public static void createDialog( ) |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
133 |
{ |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
134 |
dialog = new TestDialog( new Frame(), "Instructions" ); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
135 |
String[] defInstr = { "Instructions will appear here. ", "" } ; |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
136 |
dialog.printInstructions( defInstr ); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
137 |
dialog.setVisible(true); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
138 |
println( "Any messages for the tester will display here." ); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
139 |
} |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
140 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
141 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
142 |
public static void printInstructions( String[] instructions ) |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
143 |
{ |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
144 |
dialog.printInstructions( instructions ); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
145 |
} |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
146 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
147 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
148 |
public static void println( String messageIn ) |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
149 |
{ |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
150 |
dialog.displayMessage( messageIn ); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
151 |
} |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
152 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
153 |
public static Component getDialog() { |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
154 |
return dialog; |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
155 |
} |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
156 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
157 |
}// Sysout class |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
158 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
159 |
/** |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
160 |
This is part of the standard test machinery. It provides a place for the |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
161 |
test instructions to be displayed, and a place for interactive messages |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
162 |
to the user to be displayed. |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
163 |
To have the test instructions displayed, see Sysout. |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
164 |
To have a message to the user be displayed, see Sysout. |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
165 |
Do not call anything in this dialog directly. |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
166 |
*/ |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
167 |
class TestDialog extends Dialog |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
168 |
{ |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
169 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
170 |
TextArea instructionsText; |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
171 |
TextArea messageText; |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
172 |
int maxStringLength = 80; |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
173 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
174 |
//DO NOT call this directly, go through Sysout |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
175 |
public TestDialog( Frame frame, String name ) |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
176 |
{ |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
177 |
super( frame, name ); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
178 |
int scrollBoth = TextArea.SCROLLBARS_BOTH; |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
179 |
instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth ); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
180 |
add( "North", instructionsText ); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
181 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
182 |
messageText = new TextArea( "", 5, maxStringLength, scrollBoth ); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
183 |
add("Center", messageText); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
184 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
185 |
pack(); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
186 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
187 |
setVisible(true); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
188 |
}// TestDialog() |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
189 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
190 |
//DO NOT call this directly, go through Sysout |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
191 |
public void printInstructions( String[] instructions ) |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
192 |
{ |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
193 |
//Clear out any current instructions |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
194 |
instructionsText.setText( "" ); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
195 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
196 |
//Go down array of instruction strings |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
197 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
198 |
String printStr, remainingStr; |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
199 |
for( int i=0; i < instructions.length; i++ ) |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
200 |
{ |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
201 |
//chop up each into pieces maxSringLength long |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
202 |
remainingStr = instructions[ i ]; |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
203 |
while( remainingStr.length() > 0 ) |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
204 |
{ |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
205 |
//if longer than max then chop off first max chars to print |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
206 |
if( remainingStr.length() >= maxStringLength ) |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
207 |
{ |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
208 |
//Try to chop on a word boundary |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
209 |
int posOfSpace = remainingStr. |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
210 |
lastIndexOf( ' ', maxStringLength - 1 ); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
211 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
212 |
if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1; |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
213 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
214 |
printStr = remainingStr.substring( 0, posOfSpace + 1 ); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
215 |
remainingStr = remainingStr.substring( posOfSpace + 1 ); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
216 |
} |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
217 |
//else just print |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
218 |
else |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
219 |
{ |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
220 |
printStr = remainingStr; |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
221 |
remainingStr = ""; |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
222 |
} |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
223 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
224 |
instructionsText.append( printStr + "\n" ); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
225 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
226 |
}// while |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
227 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
228 |
}// for |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
229 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
230 |
}//printInstructions() |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
231 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
232 |
//DO NOT call this directly, go through Sysout |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
233 |
public void displayMessage( String messageIn ) |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
234 |
{ |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
235 |
messageText.append( messageIn + "\n" ); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
236 |
System.out.println(messageIn); |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
237 |
} |
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
238 |
|
3b61ff08431b
7178683: [macosx] The default directory for open dialog is different for FileDialogOpenDirTest.html
serb
parents:
diff
changeset
|
239 |
}// TestDialog class |