public abstract class AbstractFileChooser extends Object
Modifier and Type | Field and Description |
---|---|
protected static Locale |
locale
The locale for both implementations
|
Constructor and Description |
---|
AbstractFileChooser() |
Modifier and Type | Method and Description |
---|---|
abstract void |
addChoosableFileFilter(FileFilter filter)
Adds a filter to the list of user choosable file filters.
|
abstract FileFilter[] |
getChoosableFileFilters()
Gets the list of user choosable file filters.
|
abstract File |
getCurrentDirectory()
Returns the current directory.
|
abstract FileFilter |
getFileFilter()
Returns the currently selected file filter.
|
abstract File |
getSelectedFile()
Returns the selected file.
|
abstract File[] |
getSelectedFiles()
Returns a list of selected files if the file chooser is
set to allow multiple selection.
|
abstract boolean |
isMultiSelectionEnabled()
Returns true if multiple files can be selected.
|
abstract void |
setAcceptAllFileFilterUsed(boolean b)
Determines whether the
AcceptAll FileFilter is used
as an available choice in the choosable filter list. |
abstract void |
setCurrentDirectory(File dir)
Sets the current directory.
|
static void |
setDefaultLocale(Locale l)
Sets the default locale for all implementations.
|
abstract void |
setDialogTitle(String title)
Sets the string that goes in the
JFileChooser window's
title bar. |
abstract void |
setFileFilter(FileFilter filter)
Sets the current file filter.
|
abstract void |
setFileSelectionMode(int selectionMode)
Sets the
JFileChooser to allow the user to just
select files, just select
directories, or select both files and directories. |
abstract void |
setMultiSelectionEnabled(boolean multiple)
Sets the file chooser to allow multiple file selections.
|
abstract void |
setSelectedFile(File file)
Sets the selected file.
|
abstract int |
showOpenDialog(Component parent)
Pops up an "Open File" file chooser dialog.
|
abstract int |
showSaveDialog(Component parent)
Pops up a "Save File" file chooser dialog.
|
public AbstractFileChooser()
public static void setDefaultLocale(Locale l)
l
- localepublic abstract void addChoosableFileFilter(FileFilter filter)
setFileSelectionMode
.filter
- the FileFilter
to add to the choosable file
filter listgetChoosableFileFilters()
,
setFileSelectionMode(int)
public abstract FileFilter[] getChoosableFileFilters()
FileFilter
array containing all the choosable
file filtersaddChoosableFileFilter(javax.swing.filechooser.FileFilter)
public abstract File getCurrentDirectory()
setCurrentDirectory(java.io.File)
public abstract FileFilter getFileFilter()
setFileFilter(javax.swing.filechooser.FileFilter)
,
addChoosableFileFilter(javax.swing.filechooser.FileFilter)
public abstract File getSelectedFile()
setSelectedFile
or by a user action, such as
either typing the filename into the UI or selecting the
file from a list in the UI.setSelectedFile(java.io.File)
public abstract File[] getSelectedFiles()
public abstract boolean isMultiSelectionEnabled()
setMultiSelectionEnabled(boolean)
public abstract void setAcceptAllFileFilterUsed(boolean b)
AcceptAll FileFilter
is used
as an available choice in the choosable filter list.
If false, the AcceptAll
file filter is removed from
the list of available file filters.
If true, the AcceptAll
file filter will become the
the actively used file filter.b
- whether the AcceptAll FileFilter
is used
as an available choice in the choosable filter listsetFileFilter(javax.swing.filechooser.FileFilter)
public abstract void setCurrentDirectory(File dir)
null
sets the
file chooser to point to the user's default directory.
This default depends on the operating system. It is
typically the "My Documents" folder on Windows, and the user's
home directory on Unix.
If the file passed in as currentDirectory
is not a
directory, the parent of the file will be used as the currentDirectory.
If the parent is not traversable, then it will walk up the parent tree
until it finds a traversable directory, or hits the root of the
file system.dir
- the current directory to point togetCurrentDirectory()
public abstract void setDialogTitle(String title)
JFileChooser
window's
title bar.title
- the new String
for the title barpublic abstract void setFileFilter(FileFilter filter)
filter
- the new current file filter to usegetFileFilter()
public abstract void setFileSelectionMode(int selectionMode)
JFileChooser
to allow the user to just
select files, just select
directories, or select both files and directories. The default is
JFilesChooser.FILES_ONLY
.selectionMode
- the type of files to be displayed:
IllegalArgumentException
- if mode
is an illegal file selection modepublic abstract void setMultiSelectionEnabled(boolean multiple)
multiple
- true if multiple files may be selectedisMultiSelectionEnabled()
public abstract void setSelectedFile(File file)
file
- the selected filegetSelectedFile()
public abstract int showOpenDialog(Component parent)
parent
- the parent component of the dialog,
can be null
;
see showDialog
for detailsHeadlessException
- if GraphicsEnvironment.isHeadless() returns true.GraphicsEnvironment.isHeadless()
public abstract int showSaveDialog(Component parent)
parent
- the parent component of the dialog,
can be null
;
see showDialog
for detailsHeadlessException
- if GraphicsEnvironment.isHeadless() returns true.GraphicsEnvironment.isHeadless()