1 /*
2 * Copyright (c) 1995, 2014, 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
297 public FileDialog(Dialog parent, String title, int mode) {
298 super(parent, title, true);
299 this.setMode(mode);
300 setLayout(null);
301 }
302
303 /**
304 * Constructs a name for this component. Called by <code>getName()</code>
305 * when the name is <code>null</code>.
306 */
307 String constructComponentName() {
308 synchronized (FileDialog.class) {
309 return base + nameCounter++;
310 }
311 }
312
313 /**
314 * Creates the file dialog's peer. The peer allows us to change the look
315 * of the file dialog without changing its functionality.
316 */
317 @SuppressWarnings("deprecation")
318 public void addNotify() {
319 synchronized(getTreeLock()) {
320 if (parent != null && parent.getPeer() == null) {
321 parent.addNotify();
322 }
323 if (peer == null)
324 peer = getToolkit().createFileDialog(this);
325 super.addNotify();
326 }
327 }
328
329 /**
330 * Indicates whether this file dialog box is for loading from a file
331 * or for saving to a file.
332 *
333 * @return the mode of this file dialog window, either
334 * <code>FileDialog.LOAD</code> or
335 * <code>FileDialog.SAVE</code>
336 * @see java.awt.FileDialog#LOAD
337 * @see java.awt.FileDialog#SAVE
338 * @see java.awt.FileDialog#setMode
339 */
340 public int getMode() {
|
1 /*
2 * Copyright (c) 1995, 2015, 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
297 public FileDialog(Dialog parent, String title, int mode) {
298 super(parent, title, true);
299 this.setMode(mode);
300 setLayout(null);
301 }
302
303 /**
304 * Constructs a name for this component. Called by <code>getName()</code>
305 * when the name is <code>null</code>.
306 */
307 String constructComponentName() {
308 synchronized (FileDialog.class) {
309 return base + nameCounter++;
310 }
311 }
312
313 /**
314 * Creates the file dialog's peer. The peer allows us to change the look
315 * of the file dialog without changing its functionality.
316 */
317 public void addNotify() {
318 synchronized(getTreeLock()) {
319 if (parent != null && parent.peer == null) {
320 parent.addNotify();
321 }
322 if (peer == null)
323 peer = getToolkit().createFileDialog(this);
324 super.addNotify();
325 }
326 }
327
328 /**
329 * Indicates whether this file dialog box is for loading from a file
330 * or for saving to a file.
331 *
332 * @return the mode of this file dialog window, either
333 * <code>FileDialog.LOAD</code> or
334 * <code>FileDialog.SAVE</code>
335 * @see java.awt.FileDialog#LOAD
336 * @see java.awt.FileDialog#SAVE
337 * @see java.awt.FileDialog#setMode
338 */
339 public int getMode() {
|