public interface URIChooser
URIChooser provides a mechanism for the user to choose a URI.| Modifier and Type | Field and Description |
|---|---|
static int |
APPROVE_OPTION
Return value if approve (yes, ok) is chosen.
|
static java.lang.String |
APPROVE_SELECTION
Instruction to approve the current selection
(same as pressing yes or ok).
|
static int |
CANCEL_OPTION
Return value if cancel is chosen.
|
static java.lang.String |
CANCEL_SELECTION
Instruction to cancel the current selection.
|
static int |
CUSTOM_DIALOG
Type value indicating that the
URIChooser supports a
developer-specified file operation. |
static java.lang.String |
DIALOG_TITLE_PROPERTY
Identifies a change in the dialog title.
|
static int |
ERROR_OPTION
Return value if an error occured.
|
static int |
OPEN_DIALOG
Type value indicating that the
URIChooser supports an
"Open" file operation. |
static int |
SAVE_DIALOG
Type value indicating that the
URIChooser supports a
"Save" file operation. |
static java.lang.String |
SELECTED_URI_PROPERTY
Identifies a change in the selected URI.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addActionListener(java.awt.event.ActionListener l)
Adds an
ActionListener to the chooser. |
int |
getApproveButtonMnemonic()
Returns the approve button's mnemonic.
|
java.lang.String |
getApproveButtonText()
Returns the text used in the
ApproveButton . |
javax.swing.JComponent |
getComponent()
Returns the component of the URIChooser.
|
java.lang.String |
getDialogTitle()
Gets the string that goes in the
URIChooser 's titlebar. |
int |
getDialogType()
Returns the type of this dialog.
|
java.net.URI |
getSelectedURI()
Returns the selected URI.
|
void |
removeActionListener(java.awt.event.ActionListener l)
Removes an
ActionListener from the chooser. |
void |
rescanCurrentDirectory()
Tells the UI to rescan its files list from the current directory.
|
void |
setApproveButtonMnemonic(int mnemonic)
Sets the approve button's mnemonic using a numeric keycode.
|
void |
setApproveButtonText(java.lang.String approveButtonText)
Sets the text used in the
ApproveButton in the
FileChooserUI . |
void |
setDialogTitle(java.lang.String dialogTitle)
Sets the string that goes in the
URIChooser window's
title bar. |
void |
setDialogType(int dialogType)
Sets the type of this dialog.
|
void |
setSelectedURI(java.net.URI uri)
Sets the selected URI.
|
int |
showDialog(java.awt.Component parent,
java.lang.String approveButtonText)
Pops a custom file chooser dialog with a custom approve button.
|
int |
showOpenDialog(java.awt.Component parent)
Pops up an "Open" chooser dialog.
|
int |
showSaveDialog(java.awt.Component parent)
Pops up a "Save File" file chooser dialog.
|
static final int OPEN_DIALOG
URIChooser supports an
"Open" file operation.static final int SAVE_DIALOG
URIChooser supports a
"Save" file operation.static final int CUSTOM_DIALOG
URIChooser supports a
developer-specified file operation.static final int CANCEL_OPTION
static final int APPROVE_OPTION
static final int ERROR_OPTION
static final java.lang.String CANCEL_SELECTION
static final java.lang.String APPROVE_SELECTION
static final java.lang.String SELECTED_URI_PROPERTY
static final java.lang.String DIALOG_TITLE_PROPERTY
java.net.URI getSelectedURI()
setSelectedURI(java.net.URI)void setSelectedURI(java.net.URI uri)
uri - the selected uriint getDialogType()
URIChooser.OPEN_DIALOG.setDialogType(int)void setDialogType(int dialogType)
OPEN_DIALOG when you
want to bring up a chooser that the user can use to open an URI.
Likewise, use SAVE_DIALOG for letting the user choose
an URI for saving.
Use CUSTOM_DIALOG when you want to use the
chooser in a context other than "Open" or "Save".
For instance, you might want to bring up a chooser that allows
the user to choose an URI to execute. Note that you normally would not
need to set the URIChooser to use
CUSTOM_DIALOG
since a call to setApproveButtonText does this for you.
The default dialog type is URIChooser.OPEN_DIALOG.dialogType - the type of dialog to be displayed:
java.lang.IllegalArgumentException - if dialogType is
not legalgetDialogType(),
setApproveButtonText(java.lang.String)java.lang.String getApproveButtonText()
ApproveButton .
If null , the UI object will determine the button's text.
Typically, this would be "Open" or "Save".ApproveButtonsetApproveButtonText(java.lang.String),
setDialogType(int),
showDialog(java.awt.Component, java.lang.String)void setApproveButtonText(java.lang.String approveButtonText)
ApproveButton in the
FileChooserUI .approveButtonText - the text used in the ApproveButtongetApproveButtonText(),
setDialogType(int)int getApproveButtonMnemonic()
setApproveButtonMnemonic(int)void setApproveButtonMnemonic(int mnemonic)
mnemonic - an integer value for the mnemonic keygetApproveButtonMnemonic()javax.swing.JComponent getComponent()
Typically, this would return this.
void addActionListener(java.awt.event.ActionListener l)
ActionListener to the chooser.l - the listener to be addedvoid removeActionListener(java.awt.event.ActionListener l)
ActionListener from the chooser.l - the listener to be removedaddActionListener(java.awt.event.ActionListener)void setDialogTitle(java.lang.String dialogTitle)
URIChooser window's
title bar.dialogTitle - the new String for the title bargetDialogTitle()java.lang.String getDialogTitle()
URIChooser 's titlebar.setDialogTitle(java.lang.String)void rescanCurrentDirectory()
int showOpenDialog(java.awt.Component parent)
throws java.awt.HeadlessException
parent - the parent component of the dialog,
can be null;
see showDialog for detailsjava.awt.HeadlessException - if GraphicsEnvironment.isHeadless()
returns true.GraphicsEnvironment.isHeadless(),
showDialog(java.awt.Component, java.lang.String)int showSaveDialog(java.awt.Component parent)
throws java.awt.HeadlessException
parent - the parent component of the dialog,
can be null ;
see showDialog for detailsjava.awt.HeadlessException - if GraphicsEnvironment.isHeadless()
returns true.GraphicsEnvironment.isHeadless(),
showDialog(java.awt.Component, java.lang.String)int showDialog(java.awt.Component parent,
java.lang.String approveButtonText)
throws java.awt.HeadlessException
filechooser.showDialog(parentFrame, "Run Application");Alternatively, the following code does the same thing:
URIChooser chooser = new URIChooser(null);
chooser.setApproveButtonText("Run Application");
chooser.showDialog(parentFrame, null);
The parent argument determines two things:
the frame on which the open dialog depends and
the component whose position the look and feel
should consider when placing the dialog. If the parent
is a Frame</code> object (such as a <code>JFrame )
then the dialog depends on the frame and
the look and feel positions the dialog
relative to the frame (for example, centered over the frame).
If the parent is a component, then the dialog
depends on the frame containing the component,
and is positioned relative to the component
(for example, centered over the component).
If the parent is null , then the dialog depends on
no visible window, and it's placed in a
look-and-feel-dependent position
such as the center of the screen.
parent - the parent component of the dialog;
can be nullapproveButtonText - the text of the ApproveButtonjava.awt.HeadlessException - if GraphicsEnvironment.isHeadless()
returns true.GraphicsEnvironment.isHeadless()