|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectbuoy.event.EventSource
buoy.widget.Widget
buoy.widget.BFileChooser
public class BFileChooser
A BFileChooser is a Widget that allows the user to select files or directories from the file system. It has modes for loading files, saving files, and choosing directories. It supports both single and multiple selection modes, and you can optionally restrict the list of files shown in the dialog by setting a FileFilter.
BFileChooser can be used in two different ways. First, it can be added to a container like any other Widget. This is useful when you want it to appear inside of a window along with other Widgets.
Most often, however, BFileChooser is used in a modal dialog as a self contained user interface
element. To use it this way, you simply instantiate a BFileChooser, set any properties, and then
call showDialog()
to display it. showDialog()
will
automatically create a dialog, add the BFileChooser, display it, and block until the user
dismisses the dialog. You can reuse a single BFileChooser by repeatedly calling showDialog()
.
In addition to the event types generated by all Widgets, BFileChoosers generate the following event types:
Nested Class Summary | |
---|---|
static class |
BFileChooser.SelectionMode
This inner class represents a mode for the file chooser. |
Field Summary | |
---|---|
static BFileChooser.SelectionMode |
OPEN_FILE
|
static BFileChooser.SelectionMode |
SAVE_FILE
|
static BFileChooser.SelectionMode |
SELECT_FOLDER
|
Constructor Summary | |
---|---|
BFileChooser()
Create a new BFileChooser in OPEN_FILE mode. |
|
BFileChooser(BFileChooser.SelectionMode mode,
java.lang.String title)
Create a new BFileChooser |
|
BFileChooser(BFileChooser.SelectionMode mode,
java.lang.String title,
java.io.File directory)
Create a new BFileChooser. |
Method Summary | |
---|---|
javax.swing.JFileChooser |
getComponent()
Get the java.awt.Component corresponding to this Widget. |
java.io.File |
getDirectory()
Get the directory displayed in this file chooser. |
javax.swing.filechooser.FileFilter |
getFileFilter()
Get the FileFilter which restricts the list of files shown in the dialog. |
BFileChooser.SelectionMode |
getMode()
Get the select mode for this file chooser (OPEN_FILE, SAVE_FILE, or SELECT_FOLDER). |
java.io.File |
getSelectedFile()
Get the file selected in the file chooser. |
java.io.File[] |
getSelectedFiles()
Get the list of selected files. |
java.lang.String |
getTitle()
Get the title displayed on the dialog. |
boolean |
isMultipleSelectionEnabled()
Get whether the user is allowed to select multiple files. |
void |
setDirectory(java.io.File directory)
Set the directory displayed in this file chooser. |
void |
setFileFilter(javax.swing.filechooser.FileFilter filter)
Set the FileFilter which restricts the list of files shown in the dialog. |
void |
setMode(BFileChooser.SelectionMode mode)
Set the select mode for this file chooser (OPEN_FILE, SAVE_FILE, or SELECT_FOLDER). |
void |
setMultipleSelectionEnabled(boolean multiple)
Set whether the user is allowed to select multiple files. |
void |
setSelectedFile(java.io.File file)
Set the file selected in the file chooser. |
void |
setSelectedFiles(java.io.File[] files)
Set the list of selected files. |
void |
setTitle(java.lang.String title)
Set the title displayed on the dialog. |
boolean |
showDialog(Widget parent)
Show a dialog containing this BFileChooser and block until the user closes it. |
Methods inherited from class buoy.widget.Widget |
---|
addEventLink, dispatchEvent, getBackground, getBounds, getCursor, getFont, getMaximumSize, getMinimumSize, getName, getParent, getPreferredSize, hasFocus, isEnabled, isFocusable, isVisible, repaint, requestFocus, setBackground, setCursor, setEnabled, setFocusable, setFont, setName, setVisible |
Methods inherited from class buoy.event.EventSource |
---|
addEventLink, addEventLink, removeEventLink |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final BFileChooser.SelectionMode OPEN_FILE
public static final BFileChooser.SelectionMode SAVE_FILE
public static final BFileChooser.SelectionMode SELECT_FOLDER
Constructor Detail |
---|
public BFileChooser()
public BFileChooser(BFileChooser.SelectionMode mode, java.lang.String title)
mode
- the selection mode (OPEN_FILE, SAVE_FILE, or SELECT_FOLDER)title
- the title displayed on the dialogpublic BFileChooser(BFileChooser.SelectionMode mode, java.lang.String title, java.io.File directory)
mode
- the selection mode (OPEN_FILE, SAVE_FILE, or SELECT_FOLDER)title
- the title displayed on the dialogdirectory
- the directory which the file chooser should initially displayMethod Detail |
---|
public javax.swing.JFileChooser getComponent()
Widget
getComponent
in class Widget
public java.lang.String getTitle()
public void setTitle(java.lang.String title)
public BFileChooser.SelectionMode getMode()
public void setMode(BFileChooser.SelectionMode mode)
public boolean isMultipleSelectionEnabled()
public void setMultipleSelectionEnabled(boolean multiple)
public javax.swing.filechooser.FileFilter getFileFilter()
public void setFileFilter(javax.swing.filechooser.FileFilter filter)
public java.io.File getDirectory()
public void setDirectory(java.io.File directory)
public java.io.File getSelectedFile()
getSelectedFiles()
instead of this method whenever multiple selection is enabled.
If no file is selected, this returns null.
public void setSelectedFile(java.io.File file)
public java.io.File[] getSelectedFiles()
getSelectedFile()
when multiple selection is enabled.
public void setSelectedFiles(java.io.File[] files) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
- if multiple selection is not enabledpublic boolean showDialog(Widget parent)
getSelectedFile()
or getSelectedFiles()
to
determine which file or files were selected.
parent
- the dialog's parent Widget (usually a WindowWidget). This may be null.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |