public class FileChooserButton extends HBox implements FileChooser
This Widget implements the FileChooser interface, which has most of the methods necessary to manipulate the selection in the Widget.
Note that FileChooserButton only supports selecting files (mode
OPEN) or directories (mode
SELECT_FOLDER). If you need
something more complicated, then you'll need to use wrap a
FileChooserWidget in a custom Widget or launch a FileChooserDialog.
FileChooserWidget,
FileChooserDialog| Modifier and Type | Class and Description |
|---|---|
static interface |
FileChooserButton.FileSet
Signal emitted when the file indicated by this FileChooserButton has
been set by the user.
|
Widget.ButtonPressEvent, Widget.ButtonReleaseEvent, Widget.Destroy, Widget.Draw, Widget.EnterNotifyEvent, Widget.FocusInEvent, Widget.FocusOutEvent, Widget.Hide, Widget.KeyPressEvent, Widget.KeyReleaseEvent, Widget.LeaveNotifyEvent, Widget.MapEvent, Widget.MotionNotifyEvent, Widget.PopupMenu, Widget.QueryTooltip, Widget.ScrollEvent, Widget.SizeAllocate, Widget.UnmapEvent, Widget.VisibilityNotifyEvent| Constructor and Description |
|---|
FileChooserButton(String title,
FileChooserAction action)
Creates a new FileChooserButton.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addFilter(FileFilter filter)
Add a FileFilter to the list of filters that the user can select
between.
|
void |
connect(FileChooserButton.FileSet handler)
Hook up a callback to handle the
FileChooserButton.FileSet
signal generated when the file or directory has been selected by the
user using this FileChooserButton. |
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.
|
getOrientation, getSpacing, packEnd, packStart, reorderChild, setOrientation, setSpacingadd, getChildren, remove, setBorderWidthactivate, addEvents, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, destroy, getAllocatedHeight, getAllocatedWidth, getAllocation, getCanDefault, getCanFocus, getHasFocus, getName, getParent, getPreferredHeightForWidthMinimum, getPreferredHeightForWidthNatural, getPreferredHeightMinimum, getPreferredHeightNatural, getPreferredWidthForHeightMinimum, getPreferredWidthForHeightNatural, getPreferredWidthMinimum, getPreferredWidthNatural, getRequestMode, getRequisition, getSensitive, getStyleContext, getToplevel, getWindow, grabAdd, grabDefault, grabFocus, grabRemove, hide, isSensitive, overrideBackground, overrideColor, overrideFont, queueDraw, queueDrawArea, realize, setAlignHorizontal, setAlignVertical, setCanDefault, setCanFocus, setEvents, setExpandHorizontal, setExpandVertical, setName, setSensitive, setSizeRequest, setTooltipMarkup, setTooltipText, show, showAllpublic FileChooserButton(String title,
FileChooserAction action)
title - a title for the FileChooserDialog when it is popped.action - which style of FileChooser you want. Only
OPEN (selecting a single
file), and SELECT_FOLDER, (selecting a single directory) are enabled
for FileChooserButton.public void addFilter(FileFilter filter)
FileChooseraddFilter in interface FileChooserFileFilterpublic void connect(FileChooserButton.FileSet handler)
FileChooserButton.FileSet
signal generated when the file or directory has been selected by the
user using this FileChooserButton.public FileChooserAction getAction()
FileChoosergetAction in interface FileChooserFileChooser.setAction(FileChooserAction)public String getCurrentFolder()
FileChooserSELECT_FOLDER
mode. To get the currently-selected folder in that mode, you can use
FileChooser.getURI() instead.getCurrentFolder in interface FileChoosernull if if the FileChooser
was unable to load the last folder that was requested of it (as
would happen if calling FileChooser.setCurrentFolder(String) on a
nonexistent directory).FileChooser.getFilename()public String getFilename()
FileChoosergetFilename in interface FileChoosernull. 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.public FileFilter getFilter()
FileChooserThis function is specially useful on "Save" FileChoosers, to know the file type chosen by the user.
getFilter in interface FileChooserFileFilterpublic URI getURI()
FileChoosergetURI in interface FileChoosernull. 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.public void setAction(FileChooserAction action)
FileChooserSAVE but not if the action is
OPEN.setAction in interface FileChooserpublic boolean setCurrentFolder(String directory)
FileChoosersetCurrentFolder in interface FileChooserdirectory - the full path of the new current foldertrue if the folder could be changed successfully,
false otherwise.public boolean setFilename(String filename)
FileChooserIf 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.
setFilename in interface FileChooserfilename - Must be an absolute path.true if the the directory was changed (if
necessary) and a file was successfully selected.public void setFilter(FileFilter filter)
FileChooserSetting 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.
setFilter in interface FileChooserFileFilter