public interface FileChooser
FileChooserDialog
(a Dialog which
can be used as a modal popup), and FileChooserButton
(which is a
Button which displays the selected filename and pops up a FileChooserDialog
when activated).
Be aware that much of FileChooser's internal behaviour depends on the main
loop cycling; calls to methods like setCurrentFolder()
and setFilename()
will not
actually take effect until you start the main loop or return from the
current signal handler (as the case may be).
Modifier and Type | Method and Description |
---|---|
void |
addFilter(FileFilter filter)
Add a FileFilter to the list of filters that the user can select
between.
|
FileChooserAction |
getAction()
Gets the type of operation that the file chooser is performing.
|
String |
getCurrentFolder()
Get the current folder being displayed in this FileChooser.
|
String |
getFilename()
Get the filename currently selected by this FileChooser.
|
FileFilter |
getFilter()
Gets the current filter.
|
URI |
getURI()
Get the URI representing the file or directory currently selected by
this FileChooser.
|
void |
setAction(FileChooserAction action)
Sets the type of operation that the chooser is performing; the user
interface is adapted to suit the selected action.
|
boolean |
setCurrentFolder(String directory)
Set the current directory for this FileChooser.
|
boolean |
setFilename(String filename)
Set the file you want selected in the FileChooser.
|
void |
setFilter(FileFilter filter)
Sets the current filter; only the files that pass the filter will be
displayed.
|
void addFilter(FileFilter filter)
FileFilter
FileChooserAction getAction()
setAction(FileChooserAction)
String getCurrentFolder()
SELECT_FOLDER
mode. To get the currently-selected folder in that mode, you can use
getURI()
instead.null
if if the FileChooser
was unable to load the last folder that was requested of it (as
would happen if calling setCurrentFolder(String)
on a
nonexistent directory).getFilename()
String getFilename()
null
. If multiple files are selected, one of the
filenames will be returned at random. If the FileChooser is in
one of the folder modes, this returns the selected folder's
name.FileFilter getFilter()
This function is specially useful on "Save" FileChoosers, to know the file type chosen by the user.
FileFilter
URI getURI()
null
. If multiple files are selected,
one of the filenames will be returned at random. If the
FileChooser is in one of the folder modes, this returns the
selected folder's URI.void setAction(FileChooserAction action)
SAVE
but not if the action is
OPEN
.boolean setCurrentFolder(String directory)
directory
- the full path of the new current foldertrue
if the folder could be changed successfully,
false
otherwise.boolean setFilename(String filename)
If the folder currently showing in the FileChooser isn't the directory containing the filename you specify, then the FileChooser will be changed to that directory.
filename
- Must be an absolute path.true
if the the directory was changed (if
necessary) and a file was successfully selected.void setFilter(FileFilter filter)
Setting the current filter when the list of filters is empty is useful if you want to restrict the displayed set of files without letting the user change it.
FileFilter