1 /*
2 * Copyright (c) 1995, 2010, 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
440 * by the peers through the AWTAccessor API.
441 *
442 * @param directory the current directory
443 * @param files the array that contains the short names of
444 * all the files that the user selects.
445 *
446 * @see #getFiles
447 * @since 1.7
448 */
449 private void setFiles(File files[]) {
450 synchronized (getObjectLock()) {
451 this.files = files;
452 }
453 }
454
455 /**
456 * Sets the selected file for this file dialog window to be the
457 * specified file. This file becomes the default file if it is set
458 * before the file dialog window is first shown.
459 * <p>
460 * Specifying "" as the file is exactly equivalent to specifying
461 * <code>null</code>
462 * as the file.
463 *
464 * @param file the file being set
465 * @see #getFile
466 * @see #getFiles
467 */
468 public void setFile(String file) {
469 this.file = (file != null && file.equals("")) ? null : file;
470 FileDialogPeer peer = (FileDialogPeer)this.peer;
471 if (peer != null) {
472 peer.setFile(this.file);
473 }
474 }
475
476 /**
477 * Enables or disables multiple file selection for the file dialog.
478 *
479 * @param enable if {@code true}, multiple file selection is enabled;
480 * {@code false} - disabled.
481 * @see #isMultipleMode
482 * @since 1.7
|
1 /*
2 * Copyright (c) 1995, 2013, 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
440 * by the peers through the AWTAccessor API.
441 *
442 * @param directory the current directory
443 * @param files the array that contains the short names of
444 * all the files that the user selects.
445 *
446 * @see #getFiles
447 * @since 1.7
448 */
449 private void setFiles(File files[]) {
450 synchronized (getObjectLock()) {
451 this.files = files;
452 }
453 }
454
455 /**
456 * Sets the selected file for this file dialog window to be the
457 * specified file. This file becomes the default file if it is set
458 * before the file dialog window is first shown.
459 * <p>
460 * The file could be highlighted or its name could be entered depending on
461 * native file dialog implementation.
462 * <p>
463 * This method accepts full path or file name with extension when used
464 * together with <code>setDirectory()</code> method.
465 * <p>
466 * Specifying "" as the file is exactly equivalent to specifying
467 * <code>null</code> as the file.
468 *
469 * @param file the file being set
470 * @see #getFile
471 * @see #getFiles
472 */
473 public void setFile(String file) {
474 this.file = (file != null && file.equals("")) ? null : file;
475 FileDialogPeer peer = (FileDialogPeer)this.peer;
476 if (peer != null) {
477 peer.setFile(this.file);
478 }
479 }
480
481 /**
482 * Enables or disables multiple file selection for the file dialog.
483 *
484 * @param enable if {@code true}, multiple file selection is enabled;
485 * {@code false} - disabled.
486 * @see #isMultipleMode
487 * @since 1.7
|