Package java.awt Previous
Previous
Java API
Java API
Index
Index
Next
Next

Class FileDialog

Fields , Constructors , Methods

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.


Fields


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.


Constructors


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.

ParameterDescription
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 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.

ParameterDescription
parent the owner of the dialog
title the title of the Dialog
mode the mode of the Dialog


Methods


addNotify

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 .


getDirectory

public String getDirectory() 

Return Value:

Returns the directory of this dialog.


getFile

public String getFile() 

Return Value:

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 allows the user to specify which files appear in the file dialog window.

Return Value:

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.

Return Value:

Returns the mode of this file dialog window; the value is either LOAD or Save


paramString

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 .


setDirectory

public void setDirectory(String  dir) 

Sets the directory of this file dialog window to be the specified directory.

ParameterDescription
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.

ParameterDescription
file the file being set


setFilenameFilter

public void setFilenameFilter(FilenameFilter  filter) 

Sets the filename filter for this file dialog window to the specified filter.

ParameterDescription
filter the specified filter



Top© 1996 Sun Microsystems, Inc. All rights reserved.