Save This Page
Home » openjdk-7 » java » awt » [javadoc | source]
java.awt
public class: FileDialog [javadoc | source]
java.lang.Object
   Dialog
      java.awt.FileDialog
The FileDialog class displays a dialog window from which the user can select a file.

Since it is a modal dialog, when the application calls its show method to display the dialog, it blocks the rest of the application until the user has chosen a file.

Field Summary
public static final  int LOAD    This constant value indicates that the purpose of the file dialog window is to locate a file from which to read. 
public static final  int SAVE    This constant value indicates that the purpose of the file dialog window is to locate a file to which to write. 
 int mode     
 String dir     
 String file     
 FilenameFilter filter     
Constructor:
 public FileDialog(Frame parent) 
    Creates a file dialog for loading a file. The title of the file dialog is initially empty. This is a convenience method for FileDialog(parent, "", LOAD).
    Parameters:
    parent - the owner of the dialog
    since: JDK1.1 -
 public FileDialog(Dialog parent) 
 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. This is a convenience method for FileDialog(parent, title, LOAD).
    Parameters:
    parent - the owner of the dialog
    title - the title of the dialog
 public FileDialog(Dialog 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. This is a convenience method for FileDialog(parent, title, LOAD).
    Parameters:
    parent - the owner of the dialog
    title - the title of the dialog; a null value will be accepted without causing a NullPointerException to be thrown
    Throws:
    java.lang.IllegalArgumentException - if the parent's GraphicsConfiguration is not from a screen device;
    java.lang.IllegalArgumentException - if parent is null; this exception is always thrown when GraphicsEnvironment.isHeadless returns true
    Also see:
    java.awt.GraphicsEnvironment#isHeadless
    exception: java.lang.IllegalArgumentException - if the parent's GraphicsConfiguration is not from a screen device;
    exception: java.lang.IllegalArgumentException - if parent is null; this exception is always thrown when GraphicsEnvironment.isHeadless returns true
    since: 1.5 -
 public FileDialog(Frame parent,
    String title,
    int mode) 
    Creates a file dialog window with the specified title for loading or saving a file.

    If the value of mode is LOAD, then the file dialog is finding a file to read, and the files shown are those in the current directory. If the value of mode is SAVE, 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; either FileDialog.LOAD or FileDialog.SAVE
    Throws:
    IllegalArgumentException - if an illegal file dialog mode is supplied
    Also see:
    java.awt.FileDialog#LOAD
    java.awt.FileDialog#SAVE
    exception: IllegalArgumentException - if an illegal file dialog mode is supplied
 public FileDialog(Dialog parent,
    String title,
    int mode) 
    Creates a file dialog window with the specified title for loading or saving a file.

    If the value of mode is LOAD, then the file dialog is finding a file to read, and the files shown are those in the current directory. If the value of mode is SAVE, the file dialog is finding a place to write a file.

    Parameters:
    parent - the owner of the dialog
    title - the title of the dialog; a null value will be accepted without causing a NullPointerException to be thrown
    mode - the mode of the dialog; either FileDialog.LOAD or FileDialog.SAVE
    Throws:
    java.lang.IllegalArgumentException - if an illegal file dialog mode is supplied;
    java.lang.IllegalArgumentException - if the parent's GraphicsConfiguration is not from a screen device;
    java.lang.IllegalArgumentException - if parent is null; this exception is always thrown when GraphicsEnvironment.isHeadless returns true
    Also see:
    java.awt.GraphicsEnvironment#isHeadless
    java.awt.FileDialog#LOAD
    java.awt.FileDialog#SAVE
    exception: java.lang.IllegalArgumentException - if an illegal file dialog mode is supplied;
    exception: java.lang.IllegalArgumentException - if the parent's GraphicsConfiguration is not from a screen device;
    exception: java.lang.IllegalArgumentException - if parent is null; this exception is always thrown when GraphicsEnvironment.isHeadless returns true
    since: 1.5 -
Method from java.awt.FileDialog Summary:
addNotify,   constructComponentName,   getDirectory,   getFile,   getFilenameFilter,   getFiles,   getMode,   isMultipleMode,   paramString,   postsOldMouseEvents,   setDirectory,   setFile,   setFilenameFilter,   setMode,   setMultipleMode
Methods from java.lang.Object:
clone,   equals,   finalize,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from java.awt.FileDialog Detail:
 public  void addNotify() 
    Creates the file dialog's peer. The peer allows us to change the look of the file dialog without changing its functionality.
 String constructComponentName() 
    Constructs a name for this component. Called by getName() when the name is null.
 public String getDirectory() 
    Gets the directory of this file dialog.
 public String getFile() 
    Gets the selected file of this file dialog. If the user selected CANCEL, the returned file is null.
 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. Filename filters do not function in Sun's reference implementation for Microsoft Windows.
 public File[] getFiles() 
    Returns files that the user selects.

    If the user cancels the file dialog, then the method returns an empty array.

 public int getMode() 
    Indicates whether this file dialog box is for loading from a file or for saving to a file.
 public boolean isMultipleMode() 
    Returns whether the file dialog allows the multiple file selection.
 protected String paramString() 
    Returns a string representing the state of this FileDialog window. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations. The returned string may be empty but may not be null.
 boolean postsOldMouseEvents() 
 public  void setDirectory(String dir) 
    Sets the directory of this file dialog window to be the specified directory. Specifying a null or an invalid directory implies an implementation-defined default. This default will not be realized, however, until the user has selected a file. Until this point, getDirectory() will return the value passed into this method.

    Specifying "" as the directory is exactly equivalent to specifying null as the 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.

    Specifying "" as the file is exactly equivalent to specifying null as the file.

 public synchronized  void setFilenameFilter(FilenameFilter filter) 
    Sets the filename filter for this file dialog window to the specified filter. Filename filters do not function in Sun's reference implementation for Microsoft Windows.
 public  void setMode(int mode) 
    Sets the mode of the file dialog. If mode is not a legal value, an exception will be thrown and mode will not be set.
 public  void setMultipleMode(boolean enable) 
    Enables or disables multiple file selection for the file dialog.