|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Container
|
+--javax.swing.JComponent
|
+--com.zfqjava.swing.JDirChooser
JDirChooser provides a tree control to allow a user
select a directory.
Examples:
JDirChooser dirChooser = new JDirChooser();
int value = dirChooser.showDialog(null);
if(value == JDirChooser.OK_OPTION) {
File file = dirChooser.getSelectedFile();
System.out.println("Selected File: " + file);
}
| Name | Value | Default Value |
|---|---|---|
| JDirChooser.recursiveModeEnabled |
|
Boolean.FALSE |
| Inner Class Summary | |
protected class |
JDirChooser.AccessibleJDirChooser
This class implements accessibility support for the JDirChooser class. |
| Inner classes inherited from class javax.swing.JComponent |
javax.swing.JComponent.AccessibleJComponent |
| Inner classes inherited from class java.awt.Container |
java.awt.Container.AccessibleAWTContainer |
| Inner classes inherited from class java.awt.Component |
java.awt.Component.AccessibleAWTComponent |
| Field Summary | |
protected javax.accessibility.AccessibleContext |
accessibleContext
|
static int |
CANCEL_OPTION
Return value if cancel is chosen. |
static int |
DIRECTORIES_ONLY
Instruction to display only directories. |
static java.lang.String |
FILE_FILTER_CHANGED_PROPERTY
User changed the kind of files to display. |
static java.lang.String |
FILE_HIDING_CHANGED_PROPERTY
Identifies a change in the display-hidden-files property. |
static java.lang.String |
FILE_SELECTION_MODE_CHANGED_PROPERTY
Identifies a change in the kind of selection (single, multiple, etc.). |
static java.lang.String |
FILE_SYSTEM_VIEW_CHANGED_PROPERTY
Says that a different object is being used to find available drives on the system. |
static java.lang.String |
FILE_VIEW_CHANGED_PROPERTY
Says that a different object is being used to retrieve file information. |
static int |
FILES_AND_DIRECTORIES
Instruction to display both files and directories. |
static java.lang.String |
MULTI_SELECTION_ENABLED_CHANGED_PROPERTY
Enables multiple-file selections. |
static int |
OK_OPTION
Return value if ok is chosen. |
static java.lang.String |
ROOT_FILE_CHANGED_PROPERTY
Identifies change in the root directory property. |
static java.lang.String |
SELECTED_FILE_CHANGED_PROPERTY
Identifies change in user's single-file selection. |
static java.lang.String |
SELECTED_FILES_CHANGED_PROPERTY
Identifies change in user's multiple-file selection. |
| Fields inherited from class javax.swing.JComponent |
listenerList, TOOL_TIP_TEXT_KEY, ui, 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 | |
JDirChooser()
Constructs a JDirChooser pointing to the user's
root directory, in win32 platform, that's desktop. |
|
JDirChooser(java.io.File rootDirectory)
Constructs a JDirChooser using the given
directory as the root directory. |
|
JDirChooser(java.io.File rootDirectory,
javax.swing.filechooser.FileSystemView fsv)
Constructs a JDirChooser using the given root directory
and the given FileSystemView. |
|
JDirChooser(javax.swing.filechooser.FileSystemView fsv)
Constructs a JDirChooser using the given
FileSystemView. |
|
JDirChooser(java.lang.String rootDirectoryPath)
Constructs a JDirChooser use the given
directory as the root directory. |
|
JDirChooser(java.lang.String rootFilePath,
javax.swing.filechooser.FileSystemView fsv)
Constructs a JDirChooser using the given root directory path
and the the given FileSystemView. |
|
| Method Summary | |
protected javax.swing.JDialog |
createDialog(java.awt.Component parent,
java.lang.String msg,
javax.swing.Icon icon,
java.lang.String title,
JDirChooser dirChooser,
java.awt.event.ActionListener okListener,
java.awt.event.ActionListener cancelListener)
Creates the dialog for the JDirChooser. |
void |
ensureFileIsVisible(java.io.File f)
Ensure the file can visible in the JDirChooser,
the JDirChooser can be represented as a JTree,
then this can scroll it's container to make it's child visible. |
javax.accessibility.AccessibleContext |
getAccessibleContext()
Gets the AccessibleContext associated with this JDirChooser. |
javax.swing.filechooser.FileFilter |
getFileFilter()
Returns the currently selected file filter. |
int |
getFileSelectionMode()
Returns the current file-selection mode. |
javax.swing.filechooser.FileSystemView |
getFileSystemView()
Returns the file system view. |
javax.swing.filechooser.FileView |
getFileView()
Returns the current file view. |
java.io.File |
getRootFile()
Returns the root directory in use, the default is desktop in windows. |
java.io.File |
getSelectedFile()
Returns the current selected file, may be null. |
java.io.File[] |
getSelectedFiles()
Returns the current selected files if the dir chooser is set to allow multiple selection. |
DirChooserUI |
getUI()
Gets the UI object which implements the L&F for this component. |
java.lang.String |
getUIClassID()
Returns a string that specifies the name of the L&F class that renders this component. |
boolean |
isFileHidingEnabled()
Returns true if hidden files are not shown in the dir chooser, otherwise, returns false. |
boolean |
isMultiSelectionEnabled()
Returns true if multiple files can be selected. |
boolean |
isSelectable(java.io.File f)
Returns true if a file is selectable, that's mean the specify file exist in the file system. |
void |
newFolder()
Makes a new folder on current path. |
protected java.lang.String |
paramString()
Returns a string representation of this JDirChooser. |
void |
refresh()
Refreshs the current JDirChooser, this will reload the
file object from file system. |
void |
refresh(java.io.File dir)
Refresh the specify directory, this will reload the file object from file system. |
void |
setFileFilter(javax.swing.filechooser.FileFilter fileFilter)
Sets the current file filter. |
void |
setFileHidingEnabled(boolean b)
Sets file hiding on or off. |
void |
setFileSelectionMode(int mode)
Sets the JDirChooser to allow the user to just select
directories, or select both files and directories. |
void |
setFileSystemView(javax.swing.filechooser.FileSystemView fsv)
Sets the file system view that the JDirChooser uses for
accessing and creating file system resources, such as finding
the floppy drive and getting a list of root drives. |
void |
setFileView(javax.swing.filechooser.FileView fileView)
Sets the file view to used to retrieve UI information, such as the icon that represents a file or the type description of a file. |
void |
setMultiSelectionEnabled(boolean b)
Sets the file chooser to allow multiple file selections. |
void |
setRootFile(java.io.File rootFile)
Sets the JDirChooser root directory, the default is
desktop in windows. |
void |
setSelectedFile(java.io.File selectedFile)
Sets the current selected file. |
void |
setSelectedFiles(java.io.File[] selectedFiles)
Sets the current selected files if the dir chooser is set to allow multiple selection. |
int |
showDialog(java.awt.Component parent)
Pops up a dialog contains the JDirChooser and
parented to parent with the dialog having a default
title. |
int |
showDialog(java.awt.Component parent,
java.lang.String msg,
javax.swing.Icon icon)
Pops up a dialog contains the JDirChooser and parented
to parent with the dialog having a default title and
message msg and icon icon. |
int |
showDialog(java.awt.Component parent,
java.lang.String msg,
javax.swing.Icon icon,
java.lang.String title)
Pops up a dialog contains the JDirChooser, and parented
to parent with the dialog having the title
title and message msg and icon
icon. |
void |
updateUI()
Notification from the UIFactory that the L&F
has changed. |
| 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, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
| Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree |
| Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final int OK_OPTION
public static final int CANCEL_OPTION
public static final int DIRECTORIES_ONLY
public static final int FILES_AND_DIRECTORIES
public static final java.lang.String SELECTED_FILE_CHANGED_PROPERTY
public static final java.lang.String SELECTED_FILES_CHANGED_PROPERTY
public static final java.lang.String FILE_SELECTION_MODE_CHANGED_PROPERTY
public static final java.lang.String ROOT_FILE_CHANGED_PROPERTY
public static final java.lang.String MULTI_SELECTION_ENABLED_CHANGED_PROPERTY
public static final java.lang.String FILE_SYSTEM_VIEW_CHANGED_PROPERTY
public static final java.lang.String FILE_VIEW_CHANGED_PROPERTY
public static final java.lang.String FILE_HIDING_CHANGED_PROPERTY
public static final java.lang.String FILE_FILTER_CHANGED_PROPERTY
protected javax.accessibility.AccessibleContext accessibleContext
| Constructor Detail |
public JDirChooser()
JDirChooser pointing to the user's
root directory, in win32 platform, that's desktop.public JDirChooser(java.lang.String rootDirectoryPath)
JDirChooser use the given
directory as the root directory.rootDirectoryPath - a String giving the path
to directorypublic JDirChooser(java.io.File rootDirectory)
JDirChooser using the given
directory as the root directory.rootDirectory - a File giving the path
to directorypublic JDirChooser(javax.swing.filechooser.FileSystemView fsv)
JDirChooser using the given
FileSystemView.fsv - the FileSystemView object
public JDirChooser(java.lang.String rootFilePath,
javax.swing.filechooser.FileSystemView fsv)
JDirChooser using the given root directory path
and the the given FileSystemView.rootDirectoryPath - a String giving the path
to directoryfsv - the FileSystemView object
public JDirChooser(java.io.File rootDirectory,
javax.swing.filechooser.FileSystemView fsv)
JDirChooser using the given root directory
and the given FileSystemView.rootDirectory - the root file of this JDirChooserfsv - the FileSystemView object| Method Detail |
public void updateUI()
UIFactory that the L&F
has changed.updateUI in class javax.swing.JComponentJComponent.updateUI()public java.lang.String getUIClassID()
getUIClassID in class javax.swing.JComponentJComponent.getUIClassID(),
UIDefaults.getUI(javax.swing.JComponent)public DirChooserUI getUI()
public java.io.File getSelectedFile()
null.
Use getSelectedFiles() if isMultiSelectionEnabled()
return true.setSelectedFile(java.io.File)public void setSelectedFile(java.io.File selectedFile)
setSelectedFiles(java.io.File[]) if isMultiSelectionEnabled()
return true.selectedFile - the current selected filegetSelectedFile()public java.io.File[] getSelectedFiles()
getSelectedFile() if isMultiSelectionEnabled()
return false.setSelectedFiles(java.io.File[])public void setSelectedFiles(java.io.File[] selectedFiles)
setSelectedFile(java.io.File) if isMultiSelectionEnabled()
return false.selectedFiles - the current selected filesgetSelectedFiles()public void setRootFile(java.io.File rootFile)
JDirChooser root directory, the default is
desktop in windows.rootFile - the root directorygetRootFile()public java.io.File getRootFile()
setRootFile(java.io.File)public void setFileSystemView(javax.swing.filechooser.FileSystemView fsv)
JDirChooser uses for
accessing and creating file system resources, such as finding
the floppy drive and getting a list of root drives.fsv - the new FileSystemViewFileSystemViewpublic javax.swing.filechooser.FileSystemView getFileSystemView()
FileSystemView objectsetFileSystemView(javax.swing.filechooser.FileSystemView)public void setFileView(javax.swing.filechooser.FileView fileView)
getFileView()public javax.swing.filechooser.FileView getFileView()
setFileView(javax.swing.filechooser.FileView)public void setFileSelectionMode(int mode)
JDirChooser to allow the user to just select
directories, or select both files and directories. The default is
JDirChooser.DIRECTORIES_ONLY.mode - the type of files to be displayed:
java.lang.IllegalArgumentException - if mode is an
illegal modegetFileSelectionMode()public int getFileSelectionMode()
JDirChooser.DIRECTORIES_ONLY.setFileSelectionMode(int)public void setMultiSelectionEnabled(boolean b)
false.b - true if multiple files may be selectedisMultiSelectionEnabled()public boolean isMultiSelectionEnabled()
false.setMultiSelectionEnabled(boolean)public boolean isFileHidingEnabled()
true.setFileHidingEnabled(boolean)public void setFileHidingEnabled(boolean b)
FileView.
The default is true.b - the boolean value that determines whether file hiding is
turned onisFileHidingEnabled()public void setFileFilter(javax.swing.filechooser.FileFilter fileFilter)
filter - the new current file filter to usegetFileFilter()public javax.swing.filechooser.FileFilter getFileFilter()
setFileFilter(javax.swing.filechooser.FileFilter)public void ensureFileIsVisible(java.io.File f)
JDirChooser,
the JDirChooser can be represented as a JTree,
then this can scroll it's container to make it's child visible.f - the file that need visiblepublic boolean isSelectable(java.io.File f)
f - the file that need checkpublic void refresh()
JDirChooser, this will reload the
file object from file system.public void refresh(java.io.File dir)
dir - the specify directory to refreshpublic void newFolder()
public int showDialog(java.awt.Component parent)
JDirChooser and
parented to parent with the dialog having a default
title.parent - the parent of the dialogshowDialog(java.awt.Component)
public int showDialog(java.awt.Component parent,
java.lang.String msg,
javax.swing.Icon icon)
JDirChooser and parented
to parent with the dialog having a default title and
message msg and icon icon.parent - the parent of the dialogmsg - the message show in the dialogicon - the icon show in the dialogshowDialog(java.awt.Component)
public int showDialog(java.awt.Component parent,
java.lang.String msg,
javax.swing.Icon icon,
java.lang.String title)
JDirChooser, and parented
to parent with the dialog having the title
title and message msg and icon
icon.parent - the parent of the dialogmsg - the message show in the dialogicon - the icon show in the dialogtitle - the title of the dialogshowDialog(java.awt.Component)
protected javax.swing.JDialog createDialog(java.awt.Component parent,
java.lang.String msg,
javax.swing.Icon icon,
java.lang.String title,
JDirChooser dirChooser,
java.awt.event.ActionListener okListener,
java.awt.event.ActionListener cancelListener)
JDirChooser.parent - the parent of the dialogmsg - the message show in the dialogicon - the icon show in the dialogtitle - the title of the dialogprotected java.lang.String paramString()
JDirChooser.
This method
is intended to be used only for debugging purposes, and the
content and format of the returned string may vary between
implementations. The returned string may be empty but may not
be null.paramString in class javax.swing.JComponentJDirChooserpublic javax.accessibility.AccessibleContext getAccessibleContext()
getAccessibleContext in interface javax.accessibility.AccessiblegetAccessibleContext in class javax.swing.JComponent
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||