Package java.awt |
![]() Previous |
![]() Java API |
![]() Index |
![]() Next |
public class java.awt.FileDialog extends java.awt.Dialog { // Fields public final static int LOAD; public final static int SAVE; // Constructors public FileDialog(Frame parent, String title); public FileDialog(Frame parent, String title, int mode); // Methods public void addNotify(); public String getDirectory(); public String getFile(); public FilenameFilter getFilenameFilter(); public int getMode(); protected String paramString(); public void setDirectory(String dir); public void setFile(String file); public void setFilenameFilter(FilenameFilter filter); }
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 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.
public final static int LOAD = 0This constant value indicates that the file dialog window is intended to determine a file from which to read.
public final static int SAVE = 1This constant value indicates that the file dialog window is intended to determine a file to which to write.
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.
Parameter Description parent the owner of the dialog title the title of the Dialog
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 or to SAVE . 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.
Parameter Description parent the owner of the dialog title the title of the Dialog mode the mode of the Dialog
public void addNotify()This method calls the createFileDialog method of this object's toolkit in order to create a FileDialogPeer 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 .
public String getDirectory()Return Value:
Returns the directory of this dialog.
public String getFile()Return Value:
Returns the currently selected file of this file dialog window, or null if none is selected.
public FilenameFilter getFilenameFilter()Determines this file dialog's filename filter. A filename filter allows the user to specify which files appear in the file dialog window.
Return Value:
Returns this file dialog's filename filter.
public int getMode()Indicates whether this file dialog box is for loading from a file or for saving to a file.
Return Value:
Returns the mode of this file dialog window; the value is either LOAD or Save
protected String paramString()Returns the parameter string representing the state of this file dialog window. This string is useful for debugging.
Return Value:
Returns the parameter string of this file dialog window.
Overrides:
paramString in class Dialog .
public void setDirectory(String dir)Sets the directory of this file dialog window to be the specified directory.
Parameter Description dir the specific directory
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.
Parameter Description file the file being set
public void setFilenameFilter(FilenameFilter filter)Sets the filename filter for this file dialog window to the specified filter.
Parameter Description filter the specified filter