javax.swing

Class JFileChooser

public class JFileChooser extends JComponent implements Accessible

A component that provides the user a dialog box to browse through a filesystem and choose one or more files or directories. A JFileChooser can be configured to filter the displayed file list by adding a {@link FileFilter} instance using {@link #addChoosableFileFilter(FileFilter)}. Additional components can be embedded in the file chooser using {@link #setAccessory(JComponent)}. The JFileChooser properties also provide mechanisms to customize the behaviour of the file chooser.
Nested Class Summary
protected classJFileChooser.AccessibleJFileChooser
Provides the accessibility features for the JFileChooser component.
Field Summary
static StringACCEPT_ALL_FILE_FILTER_USED_CHANGED_PROPERTY
The name of the 'accept all file filter used' property.
static StringACCESSORY_CHANGED_PROPERTY
The name of the 'accessory' property.
static StringAPPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY
The name of the property for the approve button mnemonic.
static StringAPPROVE_BUTTON_TEXT_CHANGED_PROPERTY
The name of the property for the approve button text.
static StringAPPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY
The name of the property for the approve button tool tip text.
static intAPPROVE_OPTION
A return value indicating the file chooser has been closed by approving the selection.
static StringAPPROVE_SELECTION
Action command string for approving the current selection.
protected AccessibleContextaccessibleContext
The accessible context.
static intCANCEL_OPTION
A return value indicating the file chooser has been closed by cancelling.
static StringCANCEL_SELECTION
Action command string for cancelling the current selection.
static StringCHOOSABLE_FILE_FILTER_CHANGED_PROPERTY
The name of the 'choosable file filters' property.
static StringCONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY
The name of the property for control button visibility.
static intCUSTOM_DIALOG
A dialog type for some custom purpose.
static StringDIALOG_TITLE_CHANGED_PROPERTY
The name of the 'dialog title' property.
static StringDIALOG_TYPE_CHANGED_PROPERTY
The name of the 'dialog type' property.
static intDIRECTORIES_ONLY
A selection mode constant indicating acceptance of directories only.
static StringDIRECTORY_CHANGED_PROPERTY
The name of the property for the current directory.
static intERROR_OPTION
A return value indicating the file chooser has been closed by some error.
static intFILES_AND_DIRECTORIES
A selection mode constant indicating acceptance of files and directories.
static intFILES_ONLY
A selection mode constant indicating acceptance of files only.
static StringFILE_FILTER_CHANGED_PROPERTY
The name of the 'file filter' property.
static StringFILE_HIDING_CHANGED_PROPERTY
The name of the 'file hiding enabled' property.
static StringFILE_SELECTION_MODE_CHANGED_PROPERTY
The name of the 'file selection mode' property.
static StringFILE_SYSTEM_VIEW_CHANGED_PROPERTY
The name of the 'file system view' property.
static StringFILE_VIEW_CHANGED_PROPERTY
The name of the 'file view' property.
static StringMULTI_SELECTION_ENABLED_CHANGED_PROPERTY
The name of the property for multi-selection.
static intOPEN_DIALOG
A dialog type for selecting a file to open.
static intSAVE_DIALOG
A dialog type for selecting a file to save.
static StringSELECTED_FILES_CHANGED_PROPERTY
The name of the property for the selected files.
static StringSELECTED_FILE_CHANGED_PROPERTY
The name of the property for the selected file.
Constructor Summary
JFileChooser()
Creates a new JFileChooser object.
JFileChooser(String currentDirectoryPath)
Creates a new JFileChooser object.
JFileChooser(String currentDirectoryPath, FileSystemView fsv)
Creates a new JFileChooser object with the specified directory and {@link FileSystemView}.
JFileChooser(File currentDirectory)
Creates a new JFileChooser object.
JFileChooser(FileSystemView fsv)
Creates a new JFileChooser object.
JFileChooser(File currentDirectory, FileSystemView fsv)
Creates a new JFileChooser object.
Method Summary
booleanaccept(File f)
Returns true if the file is accepted by the current file filter.
voidaddActionListener(ActionListener l)
Adds an {@link ActionListener} to the file chooser.
voidaddChoosableFileFilter(FileFilter filter)
Adds a file filter to the list of available filters and sends a {@link PropertyChangeEvent} (with the property name {@link #CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY}) to all registered listeners.
voidapproveSelection()
Approves the selection.
voidcancelSelection()
Cancels the selection.
voidchangeToParentDirectory()
Called by the UI delegate when the parent directory is changed.
protected JDialogcreateDialog(Component parent)
Creates a modal dialog in which to display the file chooser.
voidensureFileIsVisible(File f)
Ensures the the specified file is visible (this is handled by the UI delegate).
protected voidfireActionPerformed(String command)
Sends an @link {ActionEvent} to all registered listeners.
FileFiltergetAcceptAllFileFilter()
Returns the 'accept all' file filter from the UI delegate.
AccessibleContextgetAccessibleContext()
Returns the object that provides accessibility features for this JFileChooser component.
JComponentgetAccessory()
Returns the accessory component for the file chooser.
ActionListener[]getActionListeners()
Returns the action listeners registered with this file chooser.
intgetApproveButtonMnemonic()
Returns the approve button mnemonic, or zero if no mnemonic has been set.
StringgetApproveButtonText()
Returns the approve button text.
StringgetApproveButtonToolTipText()
Returns the tool tip text for the approve button.
FileFilter[]getChoosableFileFilters()
Returns the available file filters for this file chooser.
booleangetControlButtonsAreShown()
Returns the flag that controls whether or not the control buttons are shown on the file chooser.
FilegetCurrentDirectory()
Returns the current directory.
StringgetDescription(File f)
Returns the description of the file, generated by the current (or default) {@link FileView}.
StringgetDialogTitle()
Returns the dialog title.
intgetDialogType()
Returns the type of file chooser.
booleangetDragEnabled()
Returns true if dragging is enabled.
FileFiltergetFileFilter()
Returns the file filter.
intgetFileSelectionMode()
Returns the file selection mode, one of: {@link #FILES_ONLY}, {@link #DIRECTORIES_ONLY} or {@link #FILES_AND_DIRECTORIES}.
FileSystemViewgetFileSystemView()
Returns the file system view being used by this file chooser.
FileViewgetFileView()
Returns the custom {@link FileView} for the file chooser.
IcongetIcon(File f)
Returns the icon provided by the current (or default) {@link FileView}.
StringgetName(File f)
Returns the name of the file, generated by the current (or default) {@link FileView}.
FilegetSelectedFile()
Returns the selected file, if there is one.
File[]getSelectedFiles()
Returns the selected file or files in an array.
StringgetTypeDescription(File f)
Returns the type description for the file, generated by the current (or default) {@link FileView}.
FileChooserUIgetUI()
Returns the UI delegate for the component.
StringgetUIClassID()
Returns the UI delegate class identifier.
booleanisAcceptAllFileFilterUsed()
Returns the flag that controls whether or not the 'accept all' file filter is included in the list of filters.
booleanisDirectorySelectionEnabled()
Returns true if directory selection is enabled, and false otherwise.
booleanisFileHidingEnabled()
Returns true if hidden files are to be hidden, and false otherwise.
booleanisFileSelectionEnabled()
Returns true if file selection is enabled, and false otherwise.
booleanisMultiSelectionEnabled()
Returns true if multiple selections are allowed within this file chooser, and false otherwise.
booleanisTraversable(File f)
Returns true if the file is traversable, and false otherwise.
protected StringparamString()
Returns a string describing the attributes for the JFileChooser component, for use in debugging.
voidremoveActionListener(ActionListener l)
Removes an {@link ActionListener} from this file chooser.
booleanremoveChoosableFileFilter(FileFilter f)
Removes a file filter from the list of available filters and sends a {@link PropertyChangeEvent} (with the property name {@link #CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY}) to all registered listeners.
voidrescanCurrentDirectory()
Rescans the current directory (this is handled by the UI delegate).
voidresetChoosableFileFilters()
Clears the list of choosable file filters and installs the 'accept all' filter from the UI delegate.
voidsetAcceptAllFileFilterUsed(boolean b)
Sets the flag that controls whether or not the 'accept all' file filter is included in the list of filters, and sends a {@link PropertyChangeEvent} (with the property name {@link #ACCEPT_ALL_FILE_FILTER_USED_CHANGED_PROPERTY}) to all registered listeners.
voidsetAccessory(JComponent newAccessory)
Sets the accessory component for the file chooser and sends a {@link PropertyChangeEvent} to all registered listeners.
voidsetApproveButtonMnemonic(int mnemonic)
Sets the mnemonic for the approve button and sends a {@link PropertyChangeEvent} (with the property name {@link #APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY}) to all registered listeners.
voidsetApproveButtonMnemonic(char mnemonic)
Sets the mnemonic for the approve button and sends a {@link PropertyChangeEvent} (with the property name {@link #APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY}) to all registered listeners.
voidsetApproveButtonText(String approveButtonText)
Sets the approve button text and fires a {@link PropertyChangeEvent} (with the property name {@link #APPROVE_BUTTON_TEXT_CHANGED_PROPERTY}) to all registered listeners.
voidsetApproveButtonToolTipText(String toolTipText)
Sets the tool tip text for the approve button and sends a {@link PropertyChangeEvent} (with the property name {@link #APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY}) to all registered listeners.
voidsetControlButtonsAreShown(boolean b)
Sets the flag that controls whether or not the control buttons are shown and, if it changes, sends a {@link PropertyChangeEvent} (with the property name {@link #CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY}) to all registered listeners.
voidsetCurrentDirectory(File dir)
Sets the current directory and fires a {@link PropertyChangeEvent} (with the property name {@link #DIRECTORY_CHANGED_PROPERTY}) to all registered listeners.
voidsetDialogTitle(String dialogTitle)
Sets the dialog title and sends a {@link PropertyChangeEvent} (with the property name {@link #DIALOG_TITLE_CHANGED_PROPERTY}) to all registered listeners.
voidsetDialogType(int dialogType)
Sets the dialog type and fires a {@link PropertyChangeEvent} (with the property name {@link #DIALOG_TYPE_CHANGED_PROPERTY}) to all registered listeners.
voidsetDragEnabled(boolean b)
Sets the dragEnabled property, this disables/enables automatic drag handling (drag and drop) on this component.
voidsetFileFilter(FileFilter filter)
Sets the file filter and sends a {@link PropertyChangeEvent} (with the property name {@link #FILE_FILTER_CHANGED_PROPERTY}) to all registered listeners.
voidsetFileHidingEnabled(boolean b)
Sets the flag that controls whether or not hidden files are displayed, and sends a {@link PropertyChangeEvent} (with the property name {@link #FILE_HIDING_CHANGED_PROPERTY}) to all registered listeners.
voidsetFileSelectionMode(int mode)
Sets the file selection mode and sends a {@link PropertyChangeEvent} to all registered listeners.
voidsetFileSystemView(FileSystemView fsv)
Sets the file system view for the file chooser and sends a {@link PropertyChangeEvent} to all registered listeners.
voidsetFileView(FileView fileView)
Sets a custom {@link FileView} for the file chooser and sends a {@link PropertyChangeEvent} to all registered listeners.
voidsetMultiSelectionEnabled(boolean b)
Sets the flag that controls whether multiple selections are allowed in this filechooser and sends a {@link PropertyChangeEvent} (with the property name {@link #MULTI_SELECTION_ENABLED_CHANGED_PROPERTY}) to all registered listeners.
voidsetSelectedFile(File file)
Sets the selected file and sends a {@link PropertyChangeEvent} to all registered listeners.
voidsetSelectedFiles(File[] selectedFiles)
Sets the selected files and sends a {@link PropertyChangeEvent} (with the name {@link #SELECTED_FILES_CHANGED_PROPERTY}) to all registered listeners.
protected voidsetup(FileSystemView view)
Sets up the file chooser.
intshowDialog(Component parent, String approveButtonText)
Displays the file chooser in a modal dialog using the {@link #CUSTOM_DIALOG} type.
intshowOpenDialog(Component parent)
Displays the file chooser in a modal dialog using the {@link #OPEN_DIALOG} type.
intshowSaveDialog(Component parent)
Displays the file chooser in a modal dialog using the {@link #SAVE_DIALOG} type.
voidupdateUI()
Installs the UI delegate for the current look and feel.

Field Detail

ACCEPT_ALL_FILE_FILTER_USED_CHANGED_PROPERTY

public static final String ACCEPT_ALL_FILE_FILTER_USED_CHANGED_PROPERTY
The name of the 'accept all file filter used' property.

See Also: JFileChooser

ACCESSORY_CHANGED_PROPERTY

public static final String ACCESSORY_CHANGED_PROPERTY
The name of the 'accessory' property.

See Also: setAccessory

APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY

public static final String APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY
The name of the property for the approve button mnemonic.

See Also: JFileChooser

APPROVE_BUTTON_TEXT_CHANGED_PROPERTY

public static final String APPROVE_BUTTON_TEXT_CHANGED_PROPERTY
The name of the property for the approve button text.

See Also: setApproveButtonText

APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY

public static final String APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY
The name of the property for the approve button tool tip text.

See Also: setApproveButtonToolTipText

APPROVE_OPTION

public static final int APPROVE_OPTION
A return value indicating the file chooser has been closed by approving the selection.

See Also: showOpenDialog showSaveDialog

APPROVE_SELECTION

public static final String APPROVE_SELECTION
Action command string for approving the current selection.

See Also: cancelSelection

accessibleContext

protected AccessibleContext accessibleContext
The accessible context.

See Also: getAccessibleContext

CANCEL_OPTION

public static final int CANCEL_OPTION
A return value indicating the file chooser has been closed by cancelling.

See Also: showOpenDialog showSaveDialog

CANCEL_SELECTION

public static final String CANCEL_SELECTION
Action command string for cancelling the current selection.

See Also: cancelSelection

CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY

public static final String CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY
The name of the 'choosable file filters' property.

See Also: addChoosableFileFilter

CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY

public static final String CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY
The name of the property for control button visibility.

See Also: JFileChooser

CUSTOM_DIALOG

public static final int CUSTOM_DIALOG
A dialog type for some custom purpose.

See Also: JFileChooser

DIALOG_TITLE_CHANGED_PROPERTY

public static final String DIALOG_TITLE_CHANGED_PROPERTY
The name of the 'dialog title' property.

See Also: setDialogTitle

DIALOG_TYPE_CHANGED_PROPERTY

public static final String DIALOG_TYPE_CHANGED_PROPERTY
The name of the 'dialog type' property.

See Also: JFileChooser

DIRECTORIES_ONLY

public static final int DIRECTORIES_ONLY
A selection mode constant indicating acceptance of directories only.

See Also: JFileChooser

DIRECTORY_CHANGED_PROPERTY

public static final String DIRECTORY_CHANGED_PROPERTY
The name of the property for the current directory.

See Also: setCurrentDirectory

ERROR_OPTION

public static final int ERROR_OPTION
A return value indicating the file chooser has been closed by some error.

See Also: showOpenDialog showSaveDialog

FILES_AND_DIRECTORIES

public static final int FILES_AND_DIRECTORIES
A selection mode constant indicating acceptance of files and directories.

See Also: JFileChooser

FILES_ONLY

public static final int FILES_ONLY
A selection mode constant indicating acceptance of files only.

See Also: JFileChooser

FILE_FILTER_CHANGED_PROPERTY

public static final String FILE_FILTER_CHANGED_PROPERTY
The name of the 'file filter' property.

See Also: setFileFilter

FILE_HIDING_CHANGED_PROPERTY

public static final String FILE_HIDING_CHANGED_PROPERTY
The name of the 'file hiding enabled' property.

See Also: JFileChooser

FILE_SELECTION_MODE_CHANGED_PROPERTY

public static final String FILE_SELECTION_MODE_CHANGED_PROPERTY
The name of the 'file selection mode' property.

See Also: JFileChooser

FILE_SYSTEM_VIEW_CHANGED_PROPERTY

public static final String FILE_SYSTEM_VIEW_CHANGED_PROPERTY
The name of the 'file system view' property.

See Also: setFileSystemView

FILE_VIEW_CHANGED_PROPERTY

public static final String FILE_VIEW_CHANGED_PROPERTY
The name of the 'file view' property.

See Also: setFileView

MULTI_SELECTION_ENABLED_CHANGED_PROPERTY

public static final String MULTI_SELECTION_ENABLED_CHANGED_PROPERTY
The name of the property for multi-selection.

See Also: JFileChooser

OPEN_DIALOG

public static final int OPEN_DIALOG
A dialog type for selecting a file to open.

See Also: JFileChooser

SAVE_DIALOG

public static final int SAVE_DIALOG
A dialog type for selecting a file to save.

See Also: JFileChooser

SELECTED_FILES_CHANGED_PROPERTY

public static final String SELECTED_FILES_CHANGED_PROPERTY
The name of the property for the selected files.

See Also: (File[])

SELECTED_FILE_CHANGED_PROPERTY

public static final String SELECTED_FILE_CHANGED_PROPERTY
The name of the property for the selected file.

See Also: setSelectedFile

Constructor Detail

JFileChooser

public JFileChooser()
Creates a new JFileChooser object.

JFileChooser

public JFileChooser(String currentDirectoryPath)
Creates a new JFileChooser object.

Parameters: currentDirectoryPath the directory that should initially be shown in the filechooser (if null, the user's home directory is used).

JFileChooser

public JFileChooser(String currentDirectoryPath, FileSystemView fsv)
Creates a new JFileChooser object with the specified directory and {@link FileSystemView}.

Parameters: currentDirectoryPath the directory that should initially be shown in the filechooser (if null, the user's home directory is used). fsv the file system view (if null, the default file system view is used).

JFileChooser

public JFileChooser(File currentDirectory)
Creates a new JFileChooser object.

Parameters: currentDirectory the directory that should initially be shown in the filechooser (if null, the user's home directory is used).

JFileChooser

public JFileChooser(FileSystemView fsv)
Creates a new JFileChooser object.

Parameters: fsv the file system view (if null, the default file system view is used).

JFileChooser

public JFileChooser(File currentDirectory, FileSystemView fsv)
Creates a new JFileChooser object.

Parameters: currentDirectory the directory that should initially be shown in the filechooser (if null, the user's home directory is used). fsv the file system view (if null, the default file system view is used).

Method Detail

accept

public boolean accept(File f)
Returns true if the file is accepted by the current file filter.

Parameters: f the file.

Returns: A boolean.

addActionListener

public void addActionListener(ActionListener l)
Adds an {@link ActionListener} to the file chooser.

Parameters: l the listener.

addChoosableFileFilter

public void addChoosableFileFilter(FileFilter filter)
Adds a file filter to the list of available filters and sends a {@link PropertyChangeEvent} (with the property name {@link #CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY}) to all registered listeners.

Parameters: filter the filter (null permitted).

approveSelection

public void approveSelection()
Approves the selection. An {@link ActionEvent} is sent to all registered listeners.

cancelSelection

public void cancelSelection()
Cancels the selection. An {@link ActionEvent} is sent to all registered listeners.

changeToParentDirectory

public void changeToParentDirectory()
Called by the UI delegate when the parent directory is changed.

createDialog

protected JDialog createDialog(Component parent)
Creates a modal dialog in which to display the file chooser.

Parameters: parent the parent component.

Returns: The dialog.

Throws: HeadlessException DOCUMENT ME!

ensureFileIsVisible

public void ensureFileIsVisible(File f)
Ensures the the specified file is visible (this is handled by the UI delegate).

Parameters: f the file.

fireActionPerformed

protected void fireActionPerformed(String command)
Sends an @link {ActionEvent} to all registered listeners.

Parameters: command the action command.

getAcceptAllFileFilter

public FileFilter getAcceptAllFileFilter()
Returns the 'accept all' file filter from the UI delegate.

Returns: The 'accept all' file filter.

getAccessibleContext

public AccessibleContext getAccessibleContext()
Returns the object that provides accessibility features for this JFileChooser component.

Returns: The accessible context (an instance of {@link AccessibleJFileChooser}).

getAccessory

public JComponent getAccessory()
Returns the accessory component for the file chooser. The default value is null.

Returns: The accessory component (possibly null).

See Also: setAccessory

getActionListeners

public ActionListener[] getActionListeners()
Returns the action listeners registered with this file chooser.

Returns: An array of listeners.

getApproveButtonMnemonic

public int getApproveButtonMnemonic()
Returns the approve button mnemonic, or zero if no mnemonic has been set.

Returns: The approve button mnemonic.

See Also: JFileChooser

getApproveButtonText

public String getApproveButtonText()
Returns the approve button text.

Returns: The approve button text (possibly null).

See Also: setApproveButtonText

getApproveButtonToolTipText

public String getApproveButtonToolTipText()
Returns the tool tip text for the approve button.

Returns: The tool tip text for the approve button.

See Also: setApproveButtonToolTipText

getChoosableFileFilters

public FileFilter[] getChoosableFileFilters()
Returns the available file filters for this file chooser.

Returns: The available file filters.

getControlButtonsAreShown

public boolean getControlButtonsAreShown()
Returns the flag that controls whether or not the control buttons are shown on the file chooser.

Returns: A boolean.

See Also: JFileChooser

getCurrentDirectory

public File getCurrentDirectory()
Returns the current directory.

Returns: The current directory.

getDescription

public String getDescription(File f)
Returns the description of the file, generated by the current (or default) {@link FileView}.

Parameters: f the file.

Returns: The file description.

getDialogTitle

public String getDialogTitle()
Returns the dialog title.

Returns: The dialog title (possibly null).

See Also: setDialogTitle

getDialogType

public int getDialogType()
Returns the type of file chooser.

Returns: {@link #OPEN_DIALOG}, {@link #SAVE_DIALOG} or {@link #CUSTOM_DIALOG}.

See Also: JFileChooser

getDragEnabled

public boolean getDragEnabled()
Returns true if dragging is enabled.

Returns: true if dragging is enabled.

getFileFilter

public FileFilter getFileFilter()
Returns the file filter.

Returns: The file filter.

See Also: setFileFilter

getFileSelectionMode

public int getFileSelectionMode()
Returns the file selection mode, one of: {@link #FILES_ONLY}, {@link #DIRECTORIES_ONLY} or {@link #FILES_AND_DIRECTORIES}. The default is {@link #FILES_ONLY}.

Returns: The file selection mode.

See Also: JFileChooser

getFileSystemView

public FileSystemView getFileSystemView()
Returns the file system view being used by this file chooser.

Returns: The file system view.

See Also: setFileSystemView

getFileView

public FileView getFileView()
Returns the custom {@link FileView} for the file chooser.

Returns: The file view (possibly null).

getIcon

public Icon getIcon(File f)
Returns the icon provided by the current (or default) {@link FileView}.

Parameters: f the file.

Returns: An icon representing the file.

getName

public String getName(File f)
Returns the name of the file, generated by the current (or default) {@link FileView}.

Parameters: f the file.

Returns: The file name.

getSelectedFile

public File getSelectedFile()
Returns the selected file, if there is one.

Returns: The selected file (possibly null).

See Also: setSelectedFile

getSelectedFiles

public File[] getSelectedFiles()
Returns the selected file or files in an array. If no files are selected, an empty array is returned.

Returns: An array of the selected files (possibly empty).

getTypeDescription

public String getTypeDescription(File f)
Returns the type description for the file, generated by the current (or default) {@link FileView}.

Parameters: f the file.

Returns: The file type description.

getUI

public FileChooserUI getUI()
Returns the UI delegate for the component.

Returns: The UI delegate.

getUIClassID

public String getUIClassID()
Returns the UI delegate class identifier.

Returns: FileChooserUI.

isAcceptAllFileFilterUsed

public boolean isAcceptAllFileFilterUsed()
Returns the flag that controls whether or not the 'accept all' file filter is included in the list of filters.

Returns: A boolean.

See Also: JFileChooser

isDirectorySelectionEnabled

public boolean isDirectorySelectionEnabled()
Returns true if directory selection is enabled, and false otherwise. Directory selection is enabled when the file selection mode is {@link #DIRECTORIES_ONLY} or {@link #FILES_AND_DIRECTORIES}.

Returns: true if file selection is enabled.

See Also: getFileSelectionMode

isFileHidingEnabled

public boolean isFileHidingEnabled()
Returns true if hidden files are to be hidden, and false otherwise.

Returns: A boolean.

See Also: JFileChooser

isFileSelectionEnabled

public boolean isFileSelectionEnabled()
Returns true if file selection is enabled, and false otherwise. File selection is enabled when the file selection mode is {@link #FILES_ONLY} or {@link #FILES_AND_DIRECTORIES}.

Returns: true if file selection is enabled.

See Also: getFileSelectionMode

isMultiSelectionEnabled

public boolean isMultiSelectionEnabled()
Returns true if multiple selections are allowed within this file chooser, and false otherwise.

Returns: A boolean.

See Also: JFileChooser

isTraversable

public boolean isTraversable(File f)
Returns true if the file is traversable, and false otherwise.

Parameters: f the file or directory.

Returns: A boolean.

paramString

protected String paramString()
Returns a string describing the attributes for the JFileChooser component, for use in debugging. The return value is guaranteed to be non-null, but the format of the string may vary between implementations.

Returns: A string describing the attributes of the JFileChooser.

removeActionListener

public void removeActionListener(ActionListener l)
Removes an {@link ActionListener} from this file chooser.

Parameters: l the listener.

removeChoosableFileFilter

public boolean removeChoosableFileFilter(FileFilter f)
Removes a file filter from the list of available filters and sends a {@link PropertyChangeEvent} (with the property name {@link #CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY}) to all registered listeners.

Parameters: f the file filter.

Returns: true if the filter was removed and false otherwise.

rescanCurrentDirectory

public void rescanCurrentDirectory()
Rescans the current directory (this is handled by the UI delegate).

resetChoosableFileFilters

public void resetChoosableFileFilters()
Clears the list of choosable file filters and installs the 'accept all' filter from the UI delegate.

setAcceptAllFileFilterUsed

public void setAcceptAllFileFilterUsed(boolean b)
Sets the flag that controls whether or not the 'accept all' file filter is included in the list of filters, and sends a {@link PropertyChangeEvent} (with the property name {@link #ACCEPT_ALL_FILE_FILTER_USED_CHANGED_PROPERTY}) to all registered listeners.

Parameters: b the new value of the flag.

setAccessory

public void setAccessory(JComponent newAccessory)
Sets the accessory component for the file chooser and sends a {@link PropertyChangeEvent} to all registered listeners. The property name is {@link #ACCESSORY_CHANGED_PROPERTY}.

Parameters: newAccessory the accessory component.

setApproveButtonMnemonic

public void setApproveButtonMnemonic(int mnemonic)
Sets the mnemonic for the approve button and sends a {@link PropertyChangeEvent} (with the property name {@link #APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY}) to all registered listeners.

Parameters: mnemonic the mnemonic.

See Also: JFileChooser

setApproveButtonMnemonic

public void setApproveButtonMnemonic(char mnemonic)
Sets the mnemonic for the approve button and sends a {@link PropertyChangeEvent} (with the property name {@link #APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY}) to all registered listeners.

Parameters: mnemonic the mnemonic.

See Also: JFileChooser

setApproveButtonText

public void setApproveButtonText(String approveButtonText)
Sets the approve button text and fires a {@link PropertyChangeEvent} (with the property name {@link #APPROVE_BUTTON_TEXT_CHANGED_PROPERTY}) to all registered listeners.

Parameters: approveButtonText the text (null permitted).

See Also: getApproveButtonText

setApproveButtonToolTipText

public void setApproveButtonToolTipText(String toolTipText)
Sets the tool tip text for the approve button and sends a {@link PropertyChangeEvent} (with the property name {@link #APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY}) to all registered listeners.

Parameters: toolTipText the text.

setControlButtonsAreShown

public void setControlButtonsAreShown(boolean b)
Sets the flag that controls whether or not the control buttons are shown and, if it changes, sends a {@link PropertyChangeEvent} (with the property name {@link #CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY}) to all registered listeners.

Parameters: b the new value for the flag.

setCurrentDirectory

public void setCurrentDirectory(File dir)
Sets the current directory and fires a {@link PropertyChangeEvent} (with the property name {@link #DIRECTORY_CHANGED_PROPERTY}) to all registered listeners. If dir is null, the current directory is set to the default directory returned by the file system view.

Parameters: dir the new directory (null permitted).

See Also: getDefaultDirectory

setDialogTitle

public void setDialogTitle(String dialogTitle)
Sets the dialog title and sends a {@link PropertyChangeEvent} (with the property name {@link #DIALOG_TITLE_CHANGED_PROPERTY}) to all registered listeners.

Parameters: dialogTitle the dialog title (null permitted).

See Also: getDialogTitle

setDialogType

public void setDialogType(int dialogType)
Sets the dialog type and fires a {@link PropertyChangeEvent} (with the property name {@link #DIALOG_TYPE_CHANGED_PROPERTY}) to all registered listeners.

Parameters: dialogType the dialog type (one of: {@link #OPEN_DIALOG}, {@link #SAVE_DIALOG}, {@link #CUSTOM_DIALOG}).

Throws: IllegalArgumentException if dialogType is not valid.

setDragEnabled

public void setDragEnabled(boolean b)
Sets the dragEnabled property, this disables/enables automatic drag handling (drag and drop) on this component. The default value of the dragEnabled property is false. Some look and feels might not support automatic drag and drop; they will ignore this property.

Parameters: b - the new dragEnabled value

setFileFilter

public void setFileFilter(FileFilter filter)
Sets the file filter and sends a {@link PropertyChangeEvent} (with the property name {@link #FILE_FILTER_CHANGED_PROPERTY}) to all registered listeners.

Parameters: filter the filter (null permitted).

setFileHidingEnabled

public void setFileHidingEnabled(boolean b)
Sets the flag that controls whether or not hidden files are displayed, and sends a {@link PropertyChangeEvent} (with the property name {@link #FILE_HIDING_CHANGED_PROPERTY}) to all registered listeners.

Parameters: b the new value of the flag.

setFileSelectionMode

public void setFileSelectionMode(int mode)
Sets the file selection mode and sends a {@link PropertyChangeEvent} to all registered listeners. The property name is {@link #FILE_SELECTION_MODE_CHANGED_PROPERTY}.

Parameters: mode the mode ({@link #FILES_ONLY}, {@link #DIRECTORIES_ONLY} or {@link #FILES_AND_DIRECTORIES}).

Throws: IllegalArgumentException if the mode is invalid.

setFileSystemView

public void setFileSystemView(FileSystemView fsv)
Sets the file system view for the file chooser and sends a {@link PropertyChangeEvent} to all registered listeners.

Parameters: fsv the file system view.

setFileView

public void setFileView(FileView fileView)
Sets a custom {@link FileView} for the file chooser and sends a {@link PropertyChangeEvent} to all registered listeners. The property name is {@link #FILE_VIEW_CHANGED_PROPERTY}.

Parameters: fileView the file view (null permitted).

See Also: getFileView

setMultiSelectionEnabled

public void setMultiSelectionEnabled(boolean b)
Sets the flag that controls whether multiple selections are allowed in this filechooser and sends a {@link PropertyChangeEvent} (with the property name {@link #MULTI_SELECTION_ENABLED_CHANGED_PROPERTY}) to all registered listeners.

Parameters: b the new value of the flag.

setSelectedFile

public void setSelectedFile(File file)
Sets the selected file and sends a {@link PropertyChangeEvent} to all registered listeners. The property name is {@link #SELECTED_FILE_CHANGED_PROPERTY}.

Parameters: file the file (null permitted).

setSelectedFiles

public void setSelectedFiles(File[] selectedFiles)
Sets the selected files and sends a {@link PropertyChangeEvent} (with the name {@link #SELECTED_FILES_CHANGED_PROPERTY}) to all registered listeners.

Parameters: selectedFiles the selected files (null permitted).

setup

protected void setup(FileSystemView view)
Sets up the file chooser. This method is called by all the constructors.

Parameters: view the file system view (if null, the default file system view is used).

See Also: getFileSystemView

showDialog

public int showDialog(Component parent, String approveButtonText)
Displays the file chooser in a modal dialog using the {@link #CUSTOM_DIALOG} type.

Parameters: parent the parent component.

Returns: A return value indicating how the dialog was closed (one of {@link #APPROVE_OPTION}, {@link #CANCEL_OPTION} and {@link #ERROR_OPTION}).

Throws: HeadlessException DOCUMENT ME!

showOpenDialog

public int showOpenDialog(Component parent)
Displays the file chooser in a modal dialog using the {@link #OPEN_DIALOG} type.

Parameters: parent the parent component.

Returns: A return value indicating how the dialog was closed (one of {@link #APPROVE_OPTION}, {@link #CANCEL_OPTION} and {@link #ERROR_OPTION}).

Throws: HeadlessException DOCUMENT ME!

showSaveDialog

public int showSaveDialog(Component parent)
Displays the file chooser in a modal dialog using the {@link #SAVE_DIALOG} type.

Parameters: parent the parent component.

Returns: A return value indicating how the dialog was closed (one of {@link #APPROVE_OPTION}, {@link #CANCEL_OPTION} and {@link #ERROR_OPTION}).

Throws: HeadlessException DOCUMENT ME!

updateUI

public void updateUI()
Installs the UI delegate for the current look and feel.