|
java-gnome version 4.0.15 | ||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Objectorg.freedesktop.bindings.Pointer
org.freedesktop.bindings.Proxy
org.gnome.glib.Object
org.gnome.gtk.Object
org.gnome.gtk.Widget
org.gnome.gtk.Container
org.gnome.gtk.Bin
org.gnome.gtk.Window
org.gnome.gtk.Dialog
org.gnome.gtk.FileChooserDialog
public class FileChooserDialog
A Dialog suitable for operations that need to select a file, such as "File -> Open" or "File -> Save" commands.
A FileChooserDialog is just a Dialog with a FileChooserWidget plus
appropriate Buttons that corresponding to the specified
FileChooserAction
. Otherwise, all the methods
provided by the FileChooser interface are available which gives you the
necessary power to manipulate the selection received from the Dialog.
Using a FileChooserDialog to open a file could go like this:
FileChooserDialog dialog; ResponseType response; // instantiate dialog = new FileChooserDialog("Open File", window, FileChooserAction.OPEN); // run the Dialog response = dialog.run(); dialog.hide(); // deal with the result if (response == ResponseType.OK) { open(dialog.getFilename()); }
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.gnome.gtk.Dialog |
---|
Dialog.Response |
Nested classes/interfaces inherited from class org.gnome.gtk.Window |
---|
Window.ConfigureEvent, Window.DeleteEvent |
Nested classes/interfaces inherited from class org.gnome.gtk.Widget |
---|
Widget.ButtonPressEvent, Widget.ButtonReleaseEvent, Widget.EnterNotifyEvent, Widget.ExposeEvent, Widget.FocusInEvent, Widget.FocusOutEvent, Widget.Hide, Widget.KeyPressEvent, Widget.KeyReleaseEvent, Widget.LeaveNotifyEvent, Widget.MapEvent, Widget.MotionNotifyEvent, Widget.PopupMenu, Widget.ScrollEvent, Widget.UnmapEvent, Widget.VisibilityNotifyEvent |
Constructor Summary | |
---|---|
FileChooserDialog(String title,
Window parent,
FileChooserAction action)
Create a new FileChooserDialog. |
Method Summary | |
---|---|
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. |
Methods inherited from class org.gnome.gtk.Dialog |
---|
add, addButton, addButton, addButton, connect, emitResponse, run |
Methods inherited from class org.gnome.gtk.Window |
---|
connect, connect, getHeight, getMaximized, getPositionX, getPositionY, getScreen, getWidth, move, present, resize, setDecorated, setDefaultSize, setFullscreen, setGravity, setIcon, setKeepAbove, setKeepBelow, setMaximize, setModal, setPosition, setResizable, setSkipPagerHint, setSkipTaskbarHint, setStick, setTitle, setTransientFor, setTypeHint |
Methods inherited from class org.gnome.gtk.Bin |
---|
getChild |
Methods inherited from class org.gnome.gtk.Container |
---|
getChildren, remove, setBorderWidth |
Methods inherited from class org.gnome.gtk.Widget |
---|
activate, addEvents, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, getAllocation, getCanDefault, getCanFocus, getHasFocus, getName, getParent, getRequisition, getToplevel, getWindow, grabAdd, grabDefault, grabFocus, grabRemove, hide, modifyBackground, modifyBase, modifyFont, modifyText, queueDraw, queueDrawArea, setCanDefault, setCanFocus, setColormap, setEvents, setName, setSensitive, setSizeRequest, setTooltipMarkup, setTooltipText, show, showAll |
Methods inherited from class org.freedesktop.bindings.Pointer |
---|
toString |
Methods inherited from class Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public FileChooserDialog(String title, Window parent, FileChooserAction action)
Buttons appropriate to each of the different FileChooserActions have
been preconfigured in the action area of the Dialog. In all
cases, the executive to go ahead with the action will be the return of
ResponseType OK
.
title
- the text to use in the title bar of the Dialog Window as
drawn by the window manager, or null
if you
want a blank title.parent
- the transient parent of the Dialog. While null
is allowed, things are designed to work properly on the
assumption that a parent is specified so it is recommended
that you do so.action
- which style of FileChooser you want.Method Detail |
---|
public void addFilter(FileFilter filter)
FileChooser
addFilter
in interface FileChooser
FileFilter
public FileChooserAction getAction()
FileChooser
getAction
in interface FileChooser
FileChooser.setAction(FileChooserAction)
public String getCurrentFolder()
FileChooser
SELECT_FOLDER
mode. To get the currently-selected folder in that mode, you can use
FileChooser.getURI()
instead.
getCurrentFolder
in interface FileChooser
null
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()
FileChooser
getFilename
in interface FileChooser
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.public FileFilter getFilter()
FileChooser
This function is specially useful on "Save" FileChoosers, to know the file type chosen by the user.
getFilter
in interface FileChooser
FileFilter
public URI getURI()
FileChooser
getURI
in interface FileChooser
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.public void setAction(FileChooserAction action)
FileChooser
SAVE
but not if the action is
OPEN
.
setAction
in interface FileChooser
public boolean setCurrentFolder(String directory)
FileChooser
setCurrentFolder
in interface FileChooser
directory
- the full path of the new current folder
true
if the folder could be changed successfully,
false
otherwise.public boolean setFilename(String filename)
FileChooser
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.
setFilename
in interface FileChooser
filename
- 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)
FileChooser
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.
setFilter
in interface FileChooser
FileFilter
|
![]() java-gnome |
||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |