com.jtechlabs.ui.widget.directorychooser
Class JDirectoryChooser

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended bycom.jtechlabs.ui.widget.directorychooser.JDirectoryChooser
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public final class JDirectoryChooser
extends javax.swing.JComponent

JDirectoryChooser component provides a GUI for navigating the file system, and then either choosing an existing directory from a tree or managing file system directories' tree structure by creating new directories, renaming, copying, moving or deleting existing directories.

To display a directory chooser, you can either add an instance of JDirectoryChooser to a container, or use the JDirectoryChooser API to show a modal dialog that contains a directory chooser.

For more information about using JDirectoryChooser, see How to Use Directory Chooser, a section in our online tutorial.

The following code pops up a directory chooser dialog with custom title and text :


 File dir = JDirectoryChooser.showDialog(
     aParent,
     initialDir,
     "Select Folder",
     "Select Working Folder"
 );

 

Version:
1.0
Author:
Aleksey Prochukhan

Nested Class Summary
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
static int ACCESS_COPY
          User can copy existing directories.
static int ACCESS_DELETE
          User can delete existing directories.
static int ACCESS_FULL
          User can do everything.
static int ACCESS_MOVE
          User can move existing directories.
static int ACCESS_NEW
          User can create new directories.
static int ACCESS_RENAME
          User can rename existing directories.
static int ICONS_CUSTOM
          Custom icons are used.
static int ICONS_DEFAULT
          Default icons are used.
static int ICONS_LOOK_AND_FEEL
          Icons from the current look&feel are be used.
static int ICONS_NATIVE
          Icons from the file system are used for drives and directories.
 
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
JDirectoryChooser()
          Creates a directory chooser component with default parameters.
JDirectoryChooser(int access)
          Creates a directory chooser component with given access rights and default icons theme .
JDirectoryChooser(int access, int iconsTheme)
          Creates directory chooser with given access rights and icons' theme.
 
Method Summary
 void addAccess(int access)
          Adds the given access rights to the set of currently assigned access rights.
 void addDirectoryChooserConfirmationListener(DirectoryChooserConfirmationListener confirmationListener)
          Allows an application to register custom DirectoryChooserConfirmation event listener.
 void addDirectoryChooserErrorListener(DirectoryChooserErrorListener errorListener)
          Allows an application to register a custom DirectoryChooserError event listener.
 void addDirectoryChooserNameRequestListener(DirectoryChooserNameRequestListener nameRequestListener)
          Allows an application to register a custom DirectoryChooserNameRequest event listener.
 void addDirectoryChooserSelectionListener(DirectoryChooserSelectionListener listener)
          Adds a listener for DirectoryChooserSelection event.
 void expandFirstRoot()
          Expands and selects the first root node in the file system directories' tree.
 void fireCopyError(DirectoryChooserErrorEvent event)
          Notifies all registered selection listeners about event.
 void fireCreateError(DirectoryChooserErrorEvent event)
          Notifies all registered selection listeners about event.
 void fireDeleteConfirmation(DirectoryChooserConfirmationEvent event)
          Notifies all registered selection listeners about event.
 void fireDeleteError(DirectoryChooserErrorEvent event)
          Notifies all registered selection listeners about event.
 void fireGeneralError(DirectoryChooserErrorEvent event)
          Notifies all registered selection listeners about event.
 void fireGetDirectoryName(DirectoryChooserNameRequestEvent event)
          Notifies all registered selection listeners about event.
 void fireMoveConfirmation(DirectoryChooserConfirmationEvent event)
          Notifies all registered selection listeners about event.
 void fireMoveError(DirectoryChooserErrorEvent event)
          Notifies all registered selection listeners about event.
 void fireRenameError(DirectoryChooserErrorEvent event)
          Notifies all registered selection listeners about event.
 void fireValueChanged(DirectoryChooserSelectionEvent event)
          Notifies all registered selection listeners about event.
 int getAccess()
          Returns a set of currently assigned access rights.
 javax.swing.AbstractAction getActionCopy()
          Returns 'Copy' action object.
 javax.swing.AbstractAction getActionCut()
          Returns 'Cut' action object.
 javax.swing.AbstractAction getActionDelete()
          Returns 'Delete' action object.
 javax.swing.AbstractAction getActionHome()
          Returns 'Home' action object.
 javax.swing.AbstractAction getActionNew()
          Returns 'New Directory' action object.
 javax.swing.AbstractAction getActionPaste()
          Returns 'Paste' action object.
 javax.swing.AbstractAction getActionRename()
          Returns 'Rename' action object.
 javax.swing.AbstractAction getActionSynchronize()
          Returns 'Synchronize' action object.
 javax.swing.Icon getCollapsedIcon()
          Returns icon assigned to display collapsed node handler.
 java.lang.String getCopyText()
          Returns text string assigned for the 'Copy' action.
 java.lang.String getCutText()
          Returns text string assigned for the 'Cut' action.
 java.lang.String getDeleteText()
          Returns text string assigned for the 'Delete' action.
 javax.swing.Icon getDirectoryIcon()
          Returns icon assigned to display directories.
 javax.swing.Icon getExpandedIcon()
          Returns icon assigned to display expanded node handler.
 java.lang.String getHomeText()
          Returns text string assigned for the 'Home' action.
 int getIconsTheme()
          Returns icons' theme being currently in use by JDirectoryChooser.
 java.lang.String getNewText()
          Returns text string assigned for the 'New Directory' action.
 java.lang.String getPasteText()
          Returns text string assigned for the 'Paste' action.
 java.lang.String getRenameText()
          Returns text string assigned for the 'Rename' action.
 javax.swing.Icon getRootIcon()
          Returns icon assigned to display the file system root(s).
 java.io.File getSelectedDirectory()
          Returns currently selected path.
 javax.swing.Icon getSelectedDirectoryIcon()
          Returns icon assigned to display the selected directory.
 java.lang.String getSynchronizeText()
          Returns text string assigned for the 'Synchronize' action.
 java.lang.String getWaitText()
          Returns text, displayed during directory expansion process.
 void removeAccess(int access)
          Removes the given access rights from the set of assigned access rights.
 void removeDirectoryChooserConfirmationListener(DirectoryChooserConfirmationListener listener)
          Removes a DirectoryChooserConfirmation listener.
 void removeDirectoryChooserErrorListener(DirectoryChooserErrorListener listener)
          Removes a DirectoryChooserError listener.
 void removeDirectoryChooserNameRequestListener(DirectoryChooserNameRequestListener listener)
          Removes a DirectoryChooserNameRequest listener.
 void removeDirectoryChooserSelectionListener(DirectoryChooserSelectionListener listener)
          Removes a DirectoryChooserSelection listener.
 void setAccess(int access)
          Assignes given access rigts to this instance of JDirectoryChooser.
 void setBorder(javax.swing.border.Border border)
          Sets the border of this component.
 void setCollapsedIcon(javax.swing.Icon icon)
          Sets icon to display the collapsed node handler.
 void setCopyText(java.lang.String text)
          Set the given text string for 'Copy' action.
 void setCutText(java.lang.String text)
          Set the given text string for 'Cut' action.
 void setDeleteText(java.lang.String text)
          Set the given text string for 'Delete' action.
 void setDirectoryIcon(javax.swing.Icon icon)
          Sets the icon to display directories.
 void setExpandedIcon(javax.swing.Icon icon)
          Sets icon to display the expanded nodes handler.
 void setHomeText(java.lang.String text)
          Set the given text string for 'Home' action.
 void setIconsTheme(int iconsTheme)
          Assignes the given icons' theme to this instance of JDirectoryChooser.
 void setNewText(java.lang.String text)
          Set the given text string for 'New Directory' action.
 void setPasteText(java.lang.String text)
          Set the given text string for 'Paste' action.
 void setRenameText(java.lang.String text)
          Set the given text string for 'Rename' action.
 void setRootIcon(javax.swing.Icon icon)
          Sets icon to display the file system root(s).
 void setSelectedDirectory(java.io.File dir)
          Sets the currently selected path.
 void setSelectedDirectoryIcon(javax.swing.Icon icon)
          Sets icon to display the selected directory.
 void setSynchronizeText(java.lang.String text)
          Set the given text string for 'Sychronize' action.
 void setWaitText(java.lang.String text)
          Sets text string to be displayed during directory expansion process.
static java.io.File showDialog(java.awt.Component parent)
          Shows a modal directory chooser dialog and blocks until the dialog is hidden.
static java.io.File showDialog(java.awt.Component parent, java.io.File initialDir)
          Shows a modal directory chooser dialog and blocks until the dialog is hidden.
static java.io.File showDialog(java.awt.Component parent, java.io.File initialDir, java.lang.String title, java.lang.String text)
          Shows a modal directory chooser dialog and blocks until the dialog is hidden.
static java.io.File showDialog(java.awt.Component parent, java.io.File initialDir, java.lang.String title, java.lang.String text, int access)
          Shows a modal directory chooser dialog and blocks until the dialog is hidden.
 void synchronize()
          Detects all external changes in the file system and updates the content of the JDirectoryChooser.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ACCESS_NEW

public static final int ACCESS_NEW
User can create new directories.

See Also:
Constant Field Values

ACCESS_DELETE

public static final int ACCESS_DELETE
User can delete existing directories.

See Also:
Constant Field Values

ACCESS_RENAME

public static final int ACCESS_RENAME
User can rename existing directories.

See Also:
Constant Field Values

ACCESS_COPY

public static final int ACCESS_COPY
User can copy existing directories.

See Also:
Constant Field Values

ACCESS_MOVE

public static final int ACCESS_MOVE
User can move existing directories.

See Also:
Constant Field Values

ACCESS_FULL

public static final int ACCESS_FULL
User can do everything.

See Also:
Constant Field Values

ICONS_DEFAULT

public static final int ICONS_DEFAULT
Default icons are used.

See Also:
Constant Field Values

ICONS_NATIVE

public static final int ICONS_NATIVE
Icons from the file system are used for drives and directories.

See Also:
Constant Field Values

ICONS_LOOK_AND_FEEL

public static final int ICONS_LOOK_AND_FEEL
Icons from the current look&feel are be used.

See Also:
Constant Field Values

ICONS_CUSTOM

public static final int ICONS_CUSTOM
Custom icons are used.

See Also:
Constant Field Values
Constructor Detail

JDirectoryChooser

public JDirectoryChooser()
Creates a directory chooser component with default parameters.


JDirectoryChooser

public JDirectoryChooser(int access)
Creates a directory chooser component with given access rights and default icons theme .

Parameters:
access - the access rights assigned to the user.

JDirectoryChooser

public JDirectoryChooser(int access,
                         int iconsTheme)
Creates directory chooser with given access rights and icons' theme.

Parameters:
access - the access rights provided to the user.
iconsTheme - the icons' theme to use.
Method Detail

getAccess

public int getAccess()
Returns a set of currently assigned access rights.

Returns:
set of currently assigned access rights.

setAccess

public void setAccess(int access)
Assignes given access rigts to this instance of JDirectoryChooser.

This method controls visibility of JDirectoryChooser UI components binded to the different functions such as creation of new directories, deleting of existing directories and so on.

Parameters:
access - the access rigts to set.

addAccess

public void addAccess(int access)
Adds the given access rights to the set of currently assigned access rights.

Parameters:
access - the new rights to be added to the current set of assigned rights.

removeAccess

public void removeAccess(int access)
Removes the given access rights from the set of assigned access rights.

Parameters:
access - the set of rights to be removed from the the current set of assigned rights.

getIconsTheme

public int getIconsTheme()
Returns icons' theme being currently in use by JDirectoryChooser.

It can be one of the following: ICONS_DEFAULT, ICONS_NATIVE, ICONS_LOOK_AND_FEEL or ICONS_CUSTOM.

Returns:
the icons theme being currently in use.

setIconsTheme

public void setIconsTheme(int iconsTheme)
Assignes the given icons' theme to this instance of JDirectoryChooser.

Parameters:
iconsTheme - the icons theme to use. It can be either ICONS_DEFAULT, ICONS_NATIVE, ICONS_LOOK_AND_FEEL or ICONS_CUSTOM.

getRootIcon

public javax.swing.Icon getRootIcon()
Returns icon assigned to display the file system root(s).

Returns:
the icon to display the file system root(s).

setRootIcon

public void setRootIcon(javax.swing.Icon icon)
Sets icon to display the file system root(s).

Parameters:
icon - the icon to display the file system root(s).

getDirectoryIcon

public javax.swing.Icon getDirectoryIcon()
Returns icon assigned to display directories.

Returns:
the icon assigned to display directories.

setDirectoryIcon

public void setDirectoryIcon(javax.swing.Icon icon)
Sets the icon to display directories.

Parameters:
icon - the icon to display directories.

getSelectedDirectoryIcon

public javax.swing.Icon getSelectedDirectoryIcon()
Returns icon assigned to display the selected directory.

Returns:
the icon assigned to display the selected directory.

setSelectedDirectoryIcon

public void setSelectedDirectoryIcon(javax.swing.Icon icon)
Sets icon to display the selected directory.

Parameters:
icon - the icon to display the selected directory.

getExpandedIcon

public javax.swing.Icon getExpandedIcon()
Returns icon assigned to display expanded node handler.

Returns:
the icon for expanded node handler.

setExpandedIcon

public void setExpandedIcon(javax.swing.Icon icon)
Sets icon to display the expanded nodes handler.

Parameters:
icon - the icon for expanded node handler.

getCollapsedIcon

public javax.swing.Icon getCollapsedIcon()
Returns icon assigned to display collapsed node handler.

Returns:
the icon for collapsed node handler.

setCollapsedIcon

public void setCollapsedIcon(javax.swing.Icon icon)
Sets icon to display the collapsed node handler.

Parameters:
icon - the icon to display the collapsed node handler.

getWaitText

public java.lang.String getWaitText()
Returns text, displayed during directory expansion process.

Returns:
the text string, displayed during directory expansion process.

setWaitText

public void setWaitText(java.lang.String text)
Sets text string to be displayed during directory expansion process.

Parameters:
text - the text string displayed during directory expansion process.

getHomeText

public java.lang.String getHomeText()
Returns text string assigned for the 'Home' action.

Returns:
the text string assigned for the 'Home' action.

setHomeText

public void setHomeText(java.lang.String text)
Set the given text string for 'Home' action.

Parameters:
text - the text string to set.

getSynchronizeText

public java.lang.String getSynchronizeText()
Returns text string assigned for the 'Synchronize' action.

Returns:
the text string assigned for the 'Synchronize' action.

setSynchronizeText

public void setSynchronizeText(java.lang.String text)
Set the given text string for 'Sychronize' action.

Parameters:
text - the text string to set.

getNewText

public java.lang.String getNewText()
Returns text string assigned for the 'New Directory' action.

Returns:
the text string assigned for the 'New Directory' action.

setNewText

public void setNewText(java.lang.String text)
Set the given text string for 'New Directory' action.

Parameters:
text - the text string to set.

getDeleteText

public java.lang.String getDeleteText()
Returns text string assigned for the 'Delete' action.

Returns:
the text string assigned for the 'Delete' action.

setDeleteText

public void setDeleteText(java.lang.String text)
Set the given text string for 'Delete' action.

Parameters:
text - the text string to set.

getRenameText

public java.lang.String getRenameText()
Returns text string assigned for the 'Rename' action.

Returns:
the text string assigned for the 'Rename' action.

setRenameText

public void setRenameText(java.lang.String text)
Set the given text string for 'Rename' action.

Parameters:
text - the text string to set.

getCopyText

public java.lang.String getCopyText()
Returns text string assigned for the 'Copy' action.

Returns:
the text string assigned for the 'Copy' action.

setCopyText

public void setCopyText(java.lang.String text)
Set the given text string for 'Copy' action.

Parameters:
text - the text string to set.

getCutText

public java.lang.String getCutText()
Returns text string assigned for the 'Cut' action.

Returns:
the text string assigned for the 'Cut' action.

setCutText

public void setCutText(java.lang.String text)
Set the given text string for 'Cut' action.

Parameters:
text - the text string to set.

getPasteText

public java.lang.String getPasteText()
Returns text string assigned for the 'Paste' action.

Returns:
the text string assigned for the 'Paste' action.

setPasteText

public void setPasteText(java.lang.String text)
Set the given text string for 'Paste' action.

Parameters:
text - the text string to set.

getActionHome

public javax.swing.AbstractAction getActionHome()
Returns 'Home' action object.

Returns:
'Home' action object.

getActionNew

public javax.swing.AbstractAction getActionNew()
Returns 'New Directory' action object.

Returns:
'New Directory' action object.

getActionDelete

public javax.swing.AbstractAction getActionDelete()
Returns 'Delete' action object.

Returns:
'Delete' action object.

getActionRename

public javax.swing.AbstractAction getActionRename()
Returns 'Rename' action object.

Returns:
'Rename' action object.

getActionCopy

public javax.swing.AbstractAction getActionCopy()
Returns 'Copy' action object.

Returns:
'Copy' action object.

getActionCut

public javax.swing.AbstractAction getActionCut()
Returns 'Cut' action object.

Returns:
'Cut' action object.

getActionPaste

public javax.swing.AbstractAction getActionPaste()
Returns 'Paste' action object.

Returns:
'Paste' action object.

getActionSynchronize

public javax.swing.AbstractAction getActionSynchronize()
Returns 'Synchronize' action object.

Returns:
'Synchronize' action object.

addDirectoryChooserSelectionListener

public void addDirectoryChooserSelectionListener(DirectoryChooserSelectionListener listener)
Adds a listener for DirectoryChooserSelection event.

Parameters:
listener - The listener that's notified when the selection in a JDirectoryChooser changes.

removeDirectoryChooserSelectionListener

public void removeDirectoryChooserSelectionListener(DirectoryChooserSelectionListener listener)
Removes a DirectoryChooserSelection listener.

Parameters:
listener - the listener to remove.

fireValueChanged

public void fireValueChanged(DirectoryChooserSelectionEvent event)
Notifies all registered selection listeners about event.

Parameters:
event - the DirectoryChooserSelectionEvent to be fired; generated by the JDirectoryChooser when selection changes.

addDirectoryChooserErrorListener

public void addDirectoryChooserErrorListener(DirectoryChooserErrorListener errorListener)
                                      throws java.util.TooManyListenersException
Allows an application to register a custom DirectoryChooserError event listener.

If an application does not register an error listener, all error events reported by the JDirectoryChooser will be silently ignored. It is recommended to notify user about errors, occured because of his actions: directory was not created, directory was not deleted, etc... By default JDirectoryChooser uses DirectoryChooserDefaultHandler to handle such errors.

Parameters:
errorListener - The listener that's notified when an error in a JDirectoryChooser happens.
Throws:
java.util.TooManyListenersException - if user tries to register more than one listener.

removeDirectoryChooserErrorListener

public void removeDirectoryChooserErrorListener(DirectoryChooserErrorListener listener)
Removes a DirectoryChooserError listener.

Parameters:
listener - the listener to remove.

fireCreateError

public void fireCreateError(DirectoryChooserErrorEvent event)
Notifies all registered selection listeners about event.

Parameters:
event - the DirectoryChooserErrorEvent to be fired; generated by the JDirectoryChooser when operation of new directory creation errored out.

fireDeleteError

public void fireDeleteError(DirectoryChooserErrorEvent event)
Notifies all registered selection listeners about event.

Parameters:
event - the DirectoryChooserErrorEvent to be fired; generated by the JDirectoryChooser when operation of existing directory deleting errored out.

fireRenameError

public void fireRenameError(DirectoryChooserErrorEvent event)
Notifies all registered selection listeners about event.

Parameters:
event - the DirectoryChooserErrorEvent to be fired; generated by the JDirectoryChooser when operation of existing directory renameing errored out.

fireMoveError

public void fireMoveError(DirectoryChooserErrorEvent event)
Notifies all registered selection listeners about event.

Parameters:
event - the DirectoryChooserErrorEvent to be fired; generated by the JDirectoryChooser when operation of moving existing directory errored out.

fireCopyError

public void fireCopyError(DirectoryChooserErrorEvent event)
Notifies all registered selection listeners about event.

Parameters:
event - the DirectoryChooserErrorEvent to be fired; generated by the JDirectoryChooser when operation of copying existing directory errored out.

fireGeneralError

public void fireGeneralError(DirectoryChooserErrorEvent event)
Notifies all registered selection listeners about event.

Parameters:
event - the DirectoryChooserErrorEvent to be fired; generated by the JDirectoryChooser when unknown error occures.

addDirectoryChooserNameRequestListener

public void addDirectoryChooserNameRequestListener(DirectoryChooserNameRequestListener nameRequestListener)
                                            throws java.util.TooManyListenersException
Allows an application to register a custom DirectoryChooserNameRequest event listener.

If an application does not register name request listener, then user will be unable to create new directories using JDirectoryChooser. By default JDirectoryChooser uses DirectoryChooserDefaultHandler as name request listener.

Parameters:
nameRequestListener - the name request listener to be used by JDirectoryChooser.
Throws:
java.util.TooManyListenersException - if user tries to register more than one listener.

removeDirectoryChooserNameRequestListener

public void removeDirectoryChooserNameRequestListener(DirectoryChooserNameRequestListener listener)
Removes a DirectoryChooserNameRequest listener.

Parameters:
listener - the listener to remove.

fireGetDirectoryName

public void fireGetDirectoryName(DirectoryChooserNameRequestEvent event)
Notifies all registered selection listeners about event.

Parameters:
event - the DirectoryChooserNameRequestEvent to be fired; generated by the JDirectoryChooser when the name for the directory is requested.

addDirectoryChooserConfirmationListener

public void addDirectoryChooserConfirmationListener(DirectoryChooserConfirmationListener confirmationListener)
                                             throws java.util.TooManyListenersException
Allows an application to register custom DirectoryChooserConfirmation event listener.

If JDirectoryChooser has no registered confirmation listener, then all operations will be performed without confirmation. It is recommended to ask user to confirm directory deleting or moving before these operations will take effect, otherwise user can accidentally lose important data. By default JDirectoryChooser uses DirectoryChooserDefaultHandler to display proper confirmation.

Parameters:
confirmationListener - The listener that's notified of DirectoryChooserConfirmation events.
Throws:
java.util.TooManyListenersException

removeDirectoryChooserConfirmationListener

public void removeDirectoryChooserConfirmationListener(DirectoryChooserConfirmationListener listener)
Removes a DirectoryChooserConfirmation listener.

Parameters:
listener - the listener to remove.

fireDeleteConfirmation

public void fireDeleteConfirmation(DirectoryChooserConfirmationEvent event)
Notifies all registered selection listeners about event.

Parameters:
event - the DirectoryChooserConfirmationEvent to be fired; generated by the JDirectoryChooser whenever users tries to delete a directory.

fireMoveConfirmation

public void fireMoveConfirmation(DirectoryChooserConfirmationEvent event)
Notifies all registered selection listeners about event.

Parameters:
event - the DirectoryChooserConfirmationEvent to be fired; generated by the JDirectoryChooser whenever users tries to move a directory.

showDialog

public static java.io.File showDialog(java.awt.Component parent)
Shows a modal directory chooser dialog and blocks until the dialog is hidden. If the user presses the "OK" button, then this method hides/disposes the dialog and returns the selected path. If the user presses the "Cancel" button or closes the dialog without pressing "OK", then this method hides/disposes the dialog and returns null.

Parameters:
parent - the parent Component for the dialog.
Returns:
the selected path or null if the user opted out.

showDialog

public static java.io.File showDialog(java.awt.Component parent,
                                      java.io.File initialDir)
Shows a modal directory chooser dialog and blocks until the dialog is hidden. If the user presses the "OK" button, then this method hides/disposes the dialog and returns the selected path. If the user presses the "Cancel" button or closes the dialog without pressing "OK", then this method hides/disposes the dialog and returns null.

Parameters:
parent - the parent Component for the dialog.
initialDir - the initial path selected when directory chooser dialog is shown.
Returns:
the selected path or null if the user opted out.

showDialog

public static java.io.File showDialog(java.awt.Component parent,
                                      java.io.File initialDir,
                                      java.lang.String title,
                                      java.lang.String text)
Shows a modal directory chooser dialog and blocks until the dialog is hidden. If the user presses the "OK" button, then this method hides/disposes the dialog and returns the selected path. If the user presses the "Cancel" button or closes the dialog without pressing "OK", then this method hides/disposes the dialog and returns null.

Parameters:
parent - the parent Component for the dialog.
initialDir - the initial path selected when directory chooser dialog is shown.
title - the custom title of the dialog.
text - the custom information text displayed in the dialog.
Returns:
the selected path or null if the user opted out.

showDialog

public static java.io.File showDialog(java.awt.Component parent,
                                      java.io.File initialDir,
                                      java.lang.String title,
                                      java.lang.String text,
                                      int access)
Shows a modal directory chooser dialog and blocks until the dialog is hidden. If the user presses the "OK" button, then this method hides/disposes the dialog and returns the selected path. If the user presses the "Cancel" button or closes the dialog without pressing "OK", then this method hides/disposes the dialog and returns null.

Parameters:
parent - the parent Component for the dialog.
initialDir - the initial path selected when directory chooser dialog is shown.
title - the custom title of the dialog.
text - the custom information text displayed in the dialog.
access - the custom access rights.
Returns:
the selected path or null if the user opted out.

setSelectedDirectory

public void setSelectedDirectory(java.io.File dir)
Sets the currently selected path.

Parameters:
dir - the directory that should be selected.

getSelectedDirectory

public java.io.File getSelectedDirectory()
Returns currently selected path.

Returns:
the currently selected path or null if nothing is selected.

synchronize

public void synchronize()
Detects all external changes in the file system and updates the content of the JDirectoryChooser.


expandFirstRoot

public void expandFirstRoot()
Expands and selects the first root node in the file system directories' tree.

If the first node is a floppy drive, then the next root node is used.


setBorder

public void setBorder(javax.swing.border.Border border)
Sets the border of this component.

Parameters:
border - the border to be rendered for this component


Copyright © 2005 JTechLabs.com All Rights Reserved.