JHotDraw 7.5.1

org.jhotdraw.gui
Interface URIChooser

All Known Implementing Classes:
JFileURIChooser

@NotNull
public interface URIChooser

URIChooser provides a mechanism for the user to choose a URI.

Version:
$Id: URIChooser.java 666 2010-07-28 19:11:46Z rawcoder $
Author:
Werner Randelshofer

Field Summary
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.
 
Method Summary
 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.
 

Field Detail

OPEN_DIALOG

static final int OPEN_DIALOG
Type value indicating that the URIChooser supports an "Open" file operation.

See Also:
Constant Field Values

SAVE_DIALOG

static final int SAVE_DIALOG
Type value indicating that the URIChooser supports a "Save" file operation.

See Also:
Constant Field Values

CUSTOM_DIALOG

static final int CUSTOM_DIALOG
Type value indicating that the URIChooser supports 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

java.net.URI getSelectedURI()
Returns the selected URI.

Returns:
the selected uri
See Also:
setSelectedURI(java.net.URI)

setSelectedURI

void setSelectedURI(java.net.URI uri)
Sets the selected URI.

Parameters:
uri - the selected uri

getDialogType

int getDialogType()
Returns the type of this dialog. The default is URIChooser.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. Use 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.

Parameters:
dialogType - the type of dialog to be displayed:
  • URIChooser.OPEN_DIALOG
  • URIChooser.SAVE_DIALOG
  • URIChooser.CUSTOM_DIALOG
Throws:
java.lang.IllegalArgumentException - if dialogType is not legal
See Also:
getDialogType(), setApproveButtonText(java.lang.String)

getApproveButtonText

@Nullable
java.lang.String getApproveButtonText()
Returns the text used in the ApproveButton . If null , 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 the ApproveButton in the FileChooserUI .

Parameters:
approveButtonText - the text used in the ApproveButton
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 an ActionListener to the chooser.

Parameters:
l - the listener to be added

removeActionListener

void removeActionListener(java.awt.event.ActionListener l)
Removes an ActionListener from 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 the URIChooser window's title bar.

Parameters:
dialogTitle - the new String for the title bar
See Also:
getDialogTitle()

getDialogTitle

java.lang.String getDialogTitle()
Gets the string that goes in the URIChooser '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 be null; see showDialog for 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 be null ; see showDialog for 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 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.

Parameters:
parent - the parent component of the dialog; can be null
approveButtonText - the text of the ApproveButton
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()

Copyright 1996-2010 (c) by the authors and contributors of the JHotDraw project.
Some rights reserved.