Packages This Package Prev Next Index
§1.15 Class FileDialog
public class java.awt.FileDialog
extends java.awt.Dialog (II-§1.12)
{
// Fields
public final static int LOAD; §1.15.1
public final static int SAVE; §1.15.2
// Constructors
public FileDialog(Frame parent, String title); §1.15.3
public FileDialog(Frame parent, String title, int mode); §1.15.4
// Methods
public void addNotify(); §1.15.5
public String getDirectory(); §1.15.6
public String getFile(); §1.15.7
public FilenameFilter getFilenameFilter(); §1.15.8
public int getMode(); §1.15.9
protected String paramString(); §1.15.10
public void setDirectory(String dir); §1.15.11
public void setFile(String file); §1.15.12
public void setFilenameFilter(FilenameFilter filter); §1.15.13
}
The class FileDialog displays a dialog window from which the user can select a file.
Since it is a modal dialog, when its show method (II-§1.42.7) is called, it blocks the rest of
the application until the user has chosen a file.
The AWT sends the file dialog window all mouse, keyboard, and focus events that occur
over it.
LOAD
public final static int LOAD = 0
- This constant value indicates that the file dialog window is intended to
determine a file from which to read.
SAVE
public final static int SAVE = 1
- This constant value indicates that the file dialog window is intended to
determine a file to which to write.
FileDialog
public FileDialog(Frame parent, String title)
- Creates a file dialog window with the specified title for loading a file. The
files shown are those in the current directory.
- Parameters:
parent
-
the owner of the dialog
title
-
the title of the Dialog
FileDialog
public FileDialog(Frame parent, String title, int mode)
- Creates a file dialog window with the specified title for loading or saving a
file.
- The mode argument must have the value LOAD (II-§1.15.1) or to
SAVE (II-§1.15.2). The value LOAD indicates that the file dialog is finding
a file to read. The value SAVE indicates that the file dialog is finding a
place to write a file.
- Parameters:
parent
-
the owner of the dialog
title
-
the title of the Dialog
mode
-
the mode of the Dialog
addNotify
public void addNotify()
- This method calls the createFileDialog method (II-§1.41.9) of this object's
toolkit (II-§1.10.20) in order to create a FileDialogPeer (II-§3.9) for this file
dialog window. The peer allows the application to change the look of a file
dialog window without changing its functionality.
- Most applications do not call this method directly.
- Overrides:
- addNotify in class Dialog (II-§1.12.3).
getDirectory
public String getDirectory()
- Returns:
- the directory of this dialog.
getFile
public String getFile()
- Returns:
- the currently selected file of this file dialog window, or null if none is
selected.
getFilenameFilter
public FilenameFilter getFilenameFilter()
- Determines this file dialog's filename filter. A filename filter (I-§2.26)
allows the user to specify which files appear in the file dialog window.
- Returns:
- this file dialog's filename filter.
getMode
public int getMode()
- Indicates whether this file dialog box is for loading from a file or for saving to a file.
- Returns:
- the mode of this file dialog window; the value is either LOAD
(II-§1.15.1) or Save (II-§1.15.2)
paramString
protected String paramString()
- Returns the parameter string representing the state of this file dialog window. This string is useful for debugging.
- Returns:
- the parameter string of this file dialog window.
- Overrides:
- paramString in class Dialog (II-§1.12.7).
setDirectory
public void setDirectory(String dir)
- Sets the directory of this file dialog window to be the specified directory.
- Parameters:
dir
-
the specific directory
setFile
public void setFile(String file)
- Sets the selected file for this file dialog window to be the specified file.
This file becomes the default file if it is set before the file dialog window is
first shown.
- Parameters:
file
-
the file being set
setFilenameFilter
public void setFilenameFilter(FilenameFilter filter)
- Sets the filename filter (I-§2.26) for this file dialog window to the specified
filter.
- Parameters:
filter
-
the specified filter
Packages This Package Prev Next Index
Java API Document (HTML generated by dkramer on April 22, 1996)
Copyright © 1996 Sun Microsystems, Inc.
All rights reserved
Please send any comments or corrections to doug.kramer@sun.com