javax.swing
public class JFileChooser extends JComponent implements Accessible
Nested Class Summary | |
---|---|
protected class | JFileChooser.AccessibleJFileChooser
Provides the accessibility features for the JFileChooser
component. |
Field Summary | |
---|---|
static String | ACCEPT_ALL_FILE_FILTER_USED_CHANGED_PROPERTY
The name of the 'accept all file filter used' property. |
static String | ACCESSORY_CHANGED_PROPERTY
The name of the 'accessory' property. |
static String | APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY
The name of the property for the approve button mnemonic. |
static String | APPROVE_BUTTON_TEXT_CHANGED_PROPERTY
The name of the property for the approve button text. |
static String | APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY
The name of the property for the approve button tool tip text. |
static int | APPROVE_OPTION
A return value indicating the file chooser has been closed by approving
the selection. |
static String | APPROVE_SELECTION
Action command string for approving the current selection. |
protected AccessibleContext | accessibleContext
The accessible context. |
static int | CANCEL_OPTION
A return value indicating the file chooser has been closed by cancelling.
|
static String | CANCEL_SELECTION
Action command string for cancelling the current selection. |
static String | CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY
The name of the 'choosable file filters' property. |
static String | CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY
The name of the property for control button visibility. |
static int | CUSTOM_DIALOG
A dialog type for some custom purpose. |
static String | DIALOG_TITLE_CHANGED_PROPERTY
The name of the 'dialog title' property. |
static String | DIALOG_TYPE_CHANGED_PROPERTY
The name of the 'dialog type' property. |
static int | DIRECTORIES_ONLY
A selection mode constant indicating acceptance of directories only. |
static String | DIRECTORY_CHANGED_PROPERTY
The name of the property for the current directory. |
static int | ERROR_OPTION
A return value indicating the file chooser has been closed by some error. |
static int | FILES_AND_DIRECTORIES
A selection mode constant indicating acceptance of files and directories. |
static int | FILES_ONLY
A selection mode constant indicating acceptance of files only. |
static String | FILE_FILTER_CHANGED_PROPERTY
The name of the 'file filter' property. |
static String | FILE_HIDING_CHANGED_PROPERTY
The name of the 'file hiding enabled' property. |
static String | FILE_SELECTION_MODE_CHANGED_PROPERTY
The name of the 'file selection mode' property. |
static String | FILE_SYSTEM_VIEW_CHANGED_PROPERTY
The name of the 'file system view' property. |
static String | FILE_VIEW_CHANGED_PROPERTY
The name of the 'file view' property. |
static String | MULTI_SELECTION_ENABLED_CHANGED_PROPERTY
The name of the property for multi-selection. |
static int | OPEN_DIALOG
A dialog type for selecting a file to open. |
static int | SAVE_DIALOG
A dialog type for selecting a file to save. |
static String | SELECTED_FILES_CHANGED_PROPERTY
The name of the property for the selected files. |
static String | SELECTED_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 | |
---|---|
boolean | accept(File f)
Returns true if the file is accepted by the current
file filter.
|
void | addActionListener(ActionListener l)
Adds an {@link ActionListener} to the file chooser.
|
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.
|
void | approveSelection()
Approves the selection. |
void | cancelSelection()
Cancels the selection. |
void | changeToParentDirectory()
Called by the UI delegate when the parent directory is changed. |
protected JDialog | createDialog(Component parent)
Creates a modal dialog in which to display the file chooser.
|
void | ensureFileIsVisible(File f)
Ensures the the specified file is visible (this is handled by the
UI delegate).
|
protected void | fireActionPerformed(String command)
Sends an @link {ActionEvent} to all registered listeners.
|
FileFilter | getAcceptAllFileFilter()
Returns the 'accept all' file filter from the UI delegate.
|
AccessibleContext | getAccessibleContext()
Returns the object that provides accessibility features for this
JFileChooser component.
|
JComponent | getAccessory()
Returns the accessory component for the file chooser. |
ActionListener[] | getActionListeners()
Returns the action listeners registered with this file chooser.
|
int | getApproveButtonMnemonic()
Returns the approve button mnemonic, or zero if no mnemonic has been set.
|
String | getApproveButtonText()
Returns the approve button text.
|
String | getApproveButtonToolTipText()
Returns the tool tip text for the approve button.
|
FileFilter[] | getChoosableFileFilters()
Returns the available file filters for this file chooser.
|
boolean | getControlButtonsAreShown()
Returns the flag that controls whether or not the control buttons are
shown on the file chooser.
|
File | getCurrentDirectory()
Returns the current directory.
|
String | getDescription(File f)
Returns the description of the file, generated by the current (or default)
{@link FileView}.
|
String | getDialogTitle()
Returns the dialog title.
|
int | getDialogType()
Returns the type of file chooser.
|
boolean | getDragEnabled()
Returns true if dragging is enabled.
|
FileFilter | getFileFilter()
Returns the file filter.
|
int | getFileSelectionMode()
Returns the file selection mode, one of: {@link #FILES_ONLY},
{@link #DIRECTORIES_ONLY} or {@link #FILES_AND_DIRECTORIES}. |
FileSystemView | getFileSystemView()
Returns the file system view being used by this file chooser.
|
FileView | getFileView()
Returns the custom {@link FileView} for the file chooser.
|
Icon | getIcon(File f)
Returns the icon provided by the current (or default) {@link FileView}.
|
String | getName(File f)
Returns the name of the file, generated by the current (or default)
{@link FileView}.
|
File | getSelectedFile()
Returns the selected file, if there is one.
|
File[] | getSelectedFiles()
Returns the selected file or files in an array. |
String | getTypeDescription(File f)
Returns the type description for the file, generated by the current (or
default) {@link FileView}.
|
FileChooserUI | getUI()
Returns the UI delegate for the component.
|
String | getUIClassID()
Returns the UI delegate class identifier.
|
boolean | isAcceptAllFileFilterUsed()
Returns the flag that controls whether or not the 'accept all' file
filter is included in the list of filters.
|
boolean | isDirectorySelectionEnabled()
Returns true if directory selection is enabled, and
false otherwise. |
boolean | isFileHidingEnabled()
Returns true if hidden files are to be hidden, and
false otherwise.
|
boolean | isFileSelectionEnabled()
Returns true if file selection is enabled, and
false otherwise. |
boolean | isMultiSelectionEnabled()
Returns true if multiple selections are allowed within this
file chooser, and false otherwise.
|
boolean | isTraversable(File f)
Returns true if the file is traversable, and
false otherwise.
|
protected String | paramString()
Returns a string describing the attributes for the
JFileChooser component, for use in debugging. |
void | removeActionListener(ActionListener l)
Removes an {@link ActionListener} from this file chooser.
|
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.
|
void | rescanCurrentDirectory()
Rescans the current directory (this is handled by the UI delegate). |
void | resetChoosableFileFilters()
Clears the list of choosable file filters and installs the 'accept all'
filter from the UI delegate. |
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.
|
void | setAccessory(JComponent newAccessory)
Sets the accessory component for the file chooser and sends a
{@link PropertyChangeEvent} to all registered listeners. |
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.
|
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.
|
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.
|
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.
|
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.
|
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. |
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.
|
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.
|
void | setDragEnabled(boolean b)
Sets the dragEnabled property, this disables/enables automatic drag
handling (drag and drop) on this component. |
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.
|
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.
|
void | setFileSelectionMode(int mode)
Sets the file selection mode and sends a {@link PropertyChangeEvent}
to all registered listeners. |
void | setFileSystemView(FileSystemView fsv)
Sets the file system view for the file chooser and sends a
{@link PropertyChangeEvent} to all registered listeners.
|
void | setFileView(FileView fileView)
Sets a custom {@link FileView} for the file chooser and sends a
{@link PropertyChangeEvent} to all registered listeners. |
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.
|
void | setSelectedFile(File file)
Sets the selected file and sends a {@link PropertyChangeEvent} to all
registered listeners. |
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.
|
protected void | setup(FileSystemView view)
Sets up the file chooser. |
int | showDialog(Component parent, String approveButtonText)
Displays the file chooser in a modal dialog using the
{@link #CUSTOM_DIALOG} type.
|
int | showOpenDialog(Component parent)
Displays the file chooser in a modal dialog using the
{@link #OPEN_DIALOG} type.
|
int | showSaveDialog(Component parent)
Displays the file chooser in a modal dialog using the
{@link #SAVE_DIALOG} type.
|
void | updateUI()
Installs the UI delegate for the current look and feel. |
See Also: JFileChooser
See Also: setAccessory
See Also: JFileChooser
See Also: setApproveButtonText
See Also: setApproveButtonToolTipText
See Also: showOpenDialog showSaveDialog
See Also: cancelSelection
See Also: getAccessibleContext
See Also: showOpenDialog showSaveDialog
See Also: cancelSelection
See Also: addChoosableFileFilter
See Also: JFileChooser
See Also: JFileChooser
See Also: setDialogTitle
See Also: JFileChooser
See Also: JFileChooser
See Also: setCurrentDirectory
See Also: showOpenDialog showSaveDialog
See Also: JFileChooser
See Also: JFileChooser
See Also: setFileFilter
See Also: JFileChooser
See Also: JFileChooser
See Also: setFileSystemView
See Also: setFileView
See Also: JFileChooser
See Also: JFileChooser
See Also: JFileChooser
See Also: (File[])
See Also: setSelectedFile
JFileChooser
object.JFileChooser
object.
Parameters: currentDirectoryPath the directory that should initially be
shown in the filechooser (if null
, the user's home
directory is used).
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
object.
Parameters: currentDirectory the directory that should initially be
shown in the filechooser (if null
, the user's home
directory is used).
JFileChooser
object.
Parameters: fsv the file system view (if null
, the default file
system view is used).
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).
true
if the file is accepted by the current
file filter.
Parameters: f the file.
Returns: A boolean.
Parameters: l the listener.
Parameters: filter the filter (null
permitted).
Parameters: parent the parent component.
Returns: The dialog.
Throws: HeadlessException DOCUMENT ME!
Parameters: f the file.
Parameters: command the action command.
Returns: The 'accept all' file filter.
JFileChooser
component.
Returns: The accessible context (an instance of {@link AccessibleJFileChooser}).
null
.
Returns: The accessory component (possibly null
).
See Also: setAccessory
Returns: An array of listeners.
Returns: The approve button mnemonic.
See Also: JFileChooser
Returns: The approve button text (possibly null
).
See Also: setApproveButtonText
Returns: The tool tip text for the approve button.
See Also: setApproveButtonToolTipText
Returns: The available file filters.
Returns: A boolean.
See Also: JFileChooser
Returns: The current directory.
Parameters: f the file.
Returns: The file description.
Returns: The dialog title (possibly null
).
See Also: setDialogTitle
Returns: {@link #OPEN_DIALOG}, {@link #SAVE_DIALOG} or {@link #CUSTOM_DIALOG}.
See Also: JFileChooser
Returns: true if dragging is enabled.
Returns: The file filter.
See Also: setFileFilter
Returns: The file selection mode.
See Also: JFileChooser
Returns: The file system view.
See Also: setFileSystemView
Returns: The file view (possibly null
).
Parameters: f the file.
Returns: An icon representing the file.
Parameters: f the file.
Returns: The file name.
Returns: The selected file (possibly null
).
See Also: setSelectedFile
Returns: An array of the selected files (possibly empty).
Parameters: f the file.
Returns: The file type description.
Returns: The UI delegate.
Returns: FileChooserUI
.
Returns: A boolean.
See Also: JFileChooser
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
true
if hidden files are to be hidden, and
false
otherwise.
Returns: A boolean.
See Also: JFileChooser
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
true
if multiple selections are allowed within this
file chooser, and false
otherwise.
Returns: A boolean.
See Also: JFileChooser
true
if the file is traversable, and
false
otherwise.
Parameters: f the file or directory.
Returns: A boolean.
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
.
Parameters: l the listener.
Parameters: f the file filter.
Returns: true
if the filter was removed and
false
otherwise.
Parameters: b the new value of the flag.
Parameters: newAccessory the accessory component.
Parameters: mnemonic the mnemonic.
See Also: JFileChooser
Parameters: mnemonic the mnemonic.
See Also: JFileChooser
Parameters: approveButtonText the text (null
permitted).
See Also: getApproveButtonText
Parameters: toolTipText the text.
Parameters: b the new value for the flag.
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
Parameters: dialogTitle the dialog title (null
permitted).
See Also: getDialogTitle
Parameters: dialogType the dialog type (one of: {@link #OPEN_DIALOG}, {@link #SAVE_DIALOG}, {@link #CUSTOM_DIALOG}).
Throws: IllegalArgumentException if dialogType
is not valid.
Parameters: b - the new dragEnabled value
Parameters: filter the filter (null
permitted).
Parameters: b the new value of the flag.
Parameters: mode the mode ({@link #FILES_ONLY}, {@link #DIRECTORIES_ONLY} or {@link #FILES_AND_DIRECTORIES}).
Throws: IllegalArgumentException if the mode is invalid.
Parameters: fsv the file system view.
Parameters: fileView the file view (null
permitted).
See Also: getFileView
Parameters: b the new value of the flag.
Parameters: file the file (null
permitted).
Parameters: selectedFiles the selected files (null
permitted).
Parameters: view the file system view (if null
, the default file
system view is used).
See Also: getFileSystemView
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!
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!
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!