Interface URIChooser
-
- All Known Implementing Classes:
- JFileURIChooser
public interface URIChooserURIChooserprovides a mechanism for the user to choose a URI.
-
-
Field Summary
Fields Modifier and Type Field and Description static intAPPROVE_OPTIONReturn value if approve (yes, ok) is chosen.static java.lang.StringAPPROVE_SELECTIONInstruction to approve the current selection (same as pressing yes or ok).static intCANCEL_OPTIONReturn value if cancel is chosen.static java.lang.StringCANCEL_SELECTIONInstruction to cancel the current selection.static intCUSTOM_DIALOGType value indicating that theURIChoosersupports a developer-specified file operation.static java.lang.StringDIALOG_TITLE_PROPERTYIdentifies a change in the dialog title.static intERROR_OPTIONReturn value if an error occured.static intOPEN_DIALOGType value indicating that theURIChoosersupports an "Open" file operation.static intSAVE_DIALOGType value indicating that theURIChoosersupports a "Save" file operation.static java.lang.StringSELECTED_URI_PROPERTYIdentifies a change in the selected URI.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description voidaddActionListener(java.awt.event.ActionListener l)Adds anActionListenerto the chooser.intgetApproveButtonMnemonic()Returns the approve button's mnemonic.java.lang.StringgetApproveButtonText()Returns the text used in theApproveButton.javax.swing.JComponentgetComponent()Returns the component of the URIChooser.java.lang.StringgetDialogTitle()Gets the string that goes in theURIChooser's titlebar.intgetDialogType()Returns the type of this dialog.java.net.URIgetSelectedURI()Returns the selected URI.voidremoveActionListener(java.awt.event.ActionListener l)Removes anActionListenerfrom the chooser.voidrescanCurrentDirectory()Tells the UI to rescan its files list from the current directory.voidsetApproveButtonMnemonic(int mnemonic)Sets the approve button's mnemonic using a numeric keycode.voidsetApproveButtonText(java.lang.String approveButtonText)Sets the text used in theApproveButtonin theFileChooserUI.voidsetDialogTitle(java.lang.String dialogTitle)Sets the string that goes in theURIChooserwindow's title bar.voidsetDialogType(int dialogType)Sets the type of this dialog.voidsetSelectedURI(java.net.URI uri)Sets the selected URI.intshowDialog(java.awt.Component parent, java.lang.String approveButtonText)Pops a custom file chooser dialog with a custom approve button.intshowOpenDialog(java.awt.Component parent)Pops up an "Open" chooser dialog.intshowSaveDialog(java.awt.Component parent)Pops up a "Save File" file chooser dialog.
-
-
-
Field Detail
-
OPEN_DIALOG
static final int OPEN_DIALOG
Type value indicating that theURIChoosersupports an "Open" file operation.- See Also:
- Constant Field Values
-
SAVE_DIALOG
static final int SAVE_DIALOG
Type value indicating that theURIChoosersupports a "Save" file operation.- See Also:
- Constant Field Values
-
CUSTOM_DIALOG
static final int CUSTOM_DIALOG
Type value indicating that theURIChoosersupports a developer-specified file operation.- See Also:
- Constant Field Values
-
CANCEL_OPTION
static final int CANCEL_OPTION
Return value if cancel is chosen.- See Also:
- Constant Field Values
-
APPROVE_OPTION
static final int APPROVE_OPTION
Return value if approve (yes, ok) is chosen.- See Also:
- Constant Field Values
-
ERROR_OPTION
static final int ERROR_OPTION
Return value if an error occured.- See Also:
- Constant Field Values
-
CANCEL_SELECTION
static final java.lang.String CANCEL_SELECTION
Instruction to cancel the current selection.- See Also:
- Constant Field Values
-
APPROVE_SELECTION
static final java.lang.String APPROVE_SELECTION
Instruction to approve the current selection (same as pressing yes or ok).- See Also:
- Constant Field Values
-
SELECTED_URI_PROPERTY
static final java.lang.String SELECTED_URI_PROPERTY
Identifies a change in the selected URI.- See Also:
- Constant Field Values
-
DIALOG_TITLE_PROPERTY
static final java.lang.String DIALOG_TITLE_PROPERTY
Identifies a change in the dialog title.- See Also:
- Constant Field Values
-
-
Method Detail
-
getSelectedURI
@Nullable java.net.URI getSelectedURI()
Returns the selected URI.- Returns:
- the selected uri
- See Also:
setSelectedURI(java.net.URI)
-
setSelectedURI
void setSelectedURI(@Nullable java.net.URI uri)
Sets the selected URI.- Parameters:
uri- the selected uri
-
getDialogType
int getDialogType()
Returns the type of this dialog. The default isURIChooser.OPEN_DIALOG.- Returns:
- the type of dialog to be displayed:
- URIChooser.OPEN_DIALOG
- URIChooser.SAVE_DIALOG
- URIChooser.CUSTOM_DIALOG
- See Also:
setDialogType(int)
-
setDialogType
void setDialogType(int dialogType)
Sets the type of this dialog. UseOPEN_DIALOGwhen you want to bring up a chooser that the user can use to open an URI. Likewise, useSAVE_DIALOGfor letting the user choose an URI for saving. UseCUSTOM_DIALOGwhen 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 theURIChooserto useCUSTOM_DIALOGsince a call tosetApproveButtonTextdoes this for you. The default dialog type isURIChooser.OPEN_DIALOG.- Parameters:
dialogType- the type of dialog to be displayed:- URIChooser.OPEN_DIALOG
- URIChooser.SAVE_DIALOG
- URIChooser.CUSTOM_DIALOG
- Throws:
java.lang.IllegalArgumentException- ifdialogTypeis not legal- See Also:
getDialogType(),setApproveButtonText(java.lang.String)
-
getApproveButtonText
@Nullable java.lang.String getApproveButtonText()
Returns the text used in theApproveButton. Ifnull, the UI object will determine the button's text. Typically, this would be "Open" or "Save".- Returns:
- the text used in the
ApproveButton - See Also:
setApproveButtonText(java.lang.String),setDialogType(int),showDialog(java.awt.Component, java.lang.String)
-
setApproveButtonText
void setApproveButtonText(java.lang.String approveButtonText)
Sets the text used in theApproveButtonin theFileChooserUI.- Parameters:
approveButtonText- the text used in theApproveButton- See Also:
getApproveButtonText(),setDialogType(int)
-
getApproveButtonMnemonic
int getApproveButtonMnemonic()
Returns the approve button's mnemonic.- Returns:
- an integer value for the mnemonic key
- See Also:
setApproveButtonMnemonic(int)
-
setApproveButtonMnemonic
void setApproveButtonMnemonic(int mnemonic)
Sets the approve button's mnemonic using a numeric keycode.- Parameters:
mnemonic- an integer value for the mnemonic key- See Also:
getApproveButtonMnemonic()
-
getComponent
javax.swing.JComponent getComponent()
Returns the component of the URIChooser.Typically, this would return
this.- Returns:
- The component.
-
addActionListener
void addActionListener(java.awt.event.ActionListener l)
Adds anActionListenerto the chooser.- Parameters:
l- the listener to be added
-
removeActionListener
void removeActionListener(java.awt.event.ActionListener l)
Removes anActionListenerfrom the chooser.- Parameters:
l- the listener to be removed- See Also:
addActionListener(java.awt.event.ActionListener)
-
setDialogTitle
void setDialogTitle(java.lang.String dialogTitle)
Sets the string that goes in theURIChooserwindow's title bar.- Parameters:
dialogTitle- the newStringfor the title bar- See Also:
getDialogTitle()
-
getDialogTitle
java.lang.String getDialogTitle()
Gets the string that goes in theURIChooser's titlebar.- See Also:
setDialogTitle(java.lang.String)
-
rescanCurrentDirectory
void rescanCurrentDirectory()
Tells the UI to rescan its files list from the current directory.
-
showOpenDialog
int showOpenDialog(@Nullable java.awt.Component parent) throws java.awt.HeadlessException
Pops up an "Open" chooser dialog. Note that the text that appears in the approve button is determined by the L&F.- Parameters:
parent- the parent component of the dialog, can benull; seeshowDialogfor details- Returns:
- the return state of the file chooser on popdown:
- URIChooser.CANCEL_OPTION
- URIChooser.APPROVE_OPTION
- URIChooser.ERROR_OPTION if an error occurs or the dialog is dismissed
- Throws:
java.awt.HeadlessException- if GraphicsEnvironment.isHeadless() returns true.- See Also:
GraphicsEnvironment.isHeadless(),showDialog(java.awt.Component, java.lang.String)
-
showSaveDialog
int showSaveDialog(@Nullable java.awt.Component parent) throws java.awt.HeadlessException
Pops up a "Save File" file chooser dialog. Note that the text that appears in the approve button is determined by the L&F.- Parameters:
parent- the parent component of the dialog, can benull; seeshowDialogfor details- Returns:
- the return state of the file chooser on popdown:
- URIChooser.CANCEL_OPTION
- URIChooser.APPROVE_OPTION
- URIChooser.ERROR_OPTION if an error occurs or the dialog is dismissed
- Throws:
java.awt.HeadlessException- if GraphicsEnvironment.isHeadless() returns true.- See Also:
GraphicsEnvironment.isHeadless(),showDialog(java.awt.Component, java.lang.String)
-
showDialog
int showDialog(@Nullable java.awt.Component parent, java.lang.String approveButtonText) throws java.awt.HeadlessException
Pops a custom file chooser dialog with a custom approve button. For example, the following code pops up a file chooser with a "Run Application" button (instead of the normal "Save" or "Open" button):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
parentargument 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 aFrame</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 isnull, 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.- Parameters:
parent- the parent component of the dialog; can benullapproveButtonText- the text of theApproveButton- Returns:
- the return state of the file chooser on popdown:
- URIChooser.CANCEL_OPTION
- URIChooser.APPROVE_OPTION
- JFileCHooser.ERROR_OPTION if an error occurs or the dialog is dismissed
- Throws:
java.awt.HeadlessException- if GraphicsEnvironment.isHeadless() returns true.- See Also:
GraphicsEnvironment.isHeadless()
-
-
DataMelt 3.0 © DataMelt by jWork.ORG