|
JComponentPack 1.5.0 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
com.zfqjava.swing.JDirChooser
public class 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 |
| Nested Class Summary | |
|---|---|
protected class |
JDirChooser.AccessibleJDirChooser
This class implements accessibility support for the JDirChooser class. |
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
JComponent.AccessibleJComponent |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
| Field Summary | |
|---|---|
protected AccessibleContext |
accessibleContext
|
static int |
CANCEL_OPTION
Return value if cancel is chosen. |
static int |
DIRECTORIES_ONLY
Instruction to display only directories. |
static String |
FILE_FILTER_CHANGED_PROPERTY
User changed the kind of files to display. |
static String |
FILE_HIDING_CHANGED_PROPERTY
Identifies a change in the display-hidden-files property. |
static String |
FILE_SELECTION_MODE_CHANGED_PROPERTY
Identifies a change in the kind of selection (single, multiple, etc.). |
static String |
FILE_SYSTEM_VIEW_CHANGED_PROPERTY
Says that a different object is being used to find available drives on the system. |
static 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 String |
MULTI_SELECTION_ENABLED_CHANGED_PROPERTY
Enables multiple-file selections. |
static int |
OK_OPTION
Return value if ok is chosen. |
static String |
ROOT_FILE_CHANGED_PROPERTY
Identifies change in the root directory property. |
static String |
SELECTED_FILE_CHANGED_PROPERTY
Identifies change in user's single-file selection. |
static 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(File rootDirectory)
Constructs a JDirChooser using the given
directory as the root directory. |
|
JDirChooser(File rootDirectory,
FileSystemView fsv)
Constructs a JDirChooser using the given root directory
and the given FileSystemView. |
|
JDirChooser(FileSystemView fsv)
Constructs a JDirChooser using the given
FileSystemView. |
|
JDirChooser(String rootDirectoryPath)
Constructs a JDirChooser use the given
directory as the root directory. |
|
JDirChooser(String rootFilePath,
FileSystemView fsv)
Constructs a JDirChooser using the given root directory path
and the the given FileSystemView. |
|
| Method Summary | |
|---|---|
protected JDialog |
createDialog(Component parent,
String msg,
Icon icon,
String title,
JDirChooser dirChooser,
ActionListener okListener,
ActionListener cancelListener)
Creates the dialog for the JDirChooser. |
void |
ensureFileIsVisible(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. |
AccessibleContext |
getAccessibleContext()
Gets the AccessibleContext associated with this JDirChooser. |
FileFilter |
getFileFilter()
Returns the currently selected file filter. |
int |
getFileSelectionMode()
Returns the current file-selection mode. |
FileSystemView |
getFileSystemView()
Returns the file system view. |
FileView |
getFileView()
Returns the current file view. |
File |
getRootFile()
Returns the root directory in use, the default is desktop in windows. |
File |
getSelectedFile()
Returns the current selected file, may be null. |
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. |
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(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 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(File dir)
Refresh the specify directory, this will reload the file object from file system. |
void |
setFileFilter(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(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(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(File rootFile)
Sets the JDirChooser root directory, the default is
desktop in windows. |
void |
setSelectedFile(File selectedFile)
Sets the current selected file. |
void |
setSelectedFiles(File[] selectedFiles)
Sets the current selected files if the dir chooser is set to allow multiple selection. |
int |
showDialog(Component parent)
Pops up a dialog contains the JDirChooser and
parented to parent with the dialog having a default
title. |
int |
showDialog(Component parent,
String msg,
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(Component parent,
String msg,
Icon icon,
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 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 String SELECTED_FILE_CHANGED_PROPERTY
public static final String SELECTED_FILES_CHANGED_PROPERTY
public static final String FILE_SELECTION_MODE_CHANGED_PROPERTY
public static final String ROOT_FILE_CHANGED_PROPERTY
public static final String MULTI_SELECTION_ENABLED_CHANGED_PROPERTY
public static final String FILE_SYSTEM_VIEW_CHANGED_PROPERTY
public static final String FILE_VIEW_CHANGED_PROPERTY
public static final String FILE_HIDING_CHANGED_PROPERTY
public static final String FILE_FILTER_CHANGED_PROPERTY
protected AccessibleContext accessibleContext
| Constructor Detail |
|---|
public JDirChooser()
JDirChooser pointing to the user's
root directory, in win32 platform, that's desktop.
public JDirChooser(String rootDirectoryPath)
JDirChooser use the given
directory as the root directory.
rootDirectoryPath - a String giving the path
to directorypublic JDirChooser(File rootDirectory)
JDirChooser using the given
directory as the root directory.
rootDirectory - a File giving the path
to directorypublic JDirChooser(FileSystemView fsv)
JDirChooser using the given
FileSystemView.
fsv - the FileSystemView object
public JDirChooser(String rootFilePath,
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(File rootDirectory,
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 JComponentJComponent.updateUI()public String getUIClassID()
getUIClassID in class JComponentJComponent.getUIClassID(),
UIDefaults.getUI(javax.swing.JComponent)public DirChooserUI getUI()
public File getSelectedFile()
null.
Use getSelectedFiles() if isMultiSelectionEnabled()
return true.
setSelectedFile(java.io.File)public void setSelectedFile(File selectedFile)
setSelectedFiles(java.io.File[]) if isMultiSelectionEnabled()
return true.
selectedFile - the current selected filegetSelectedFile()public File[] getSelectedFiles()
getSelectedFile() if isMultiSelectionEnabled()
return false.
setSelectedFiles(java.io.File[])public void setSelectedFiles(File[] selectedFiles)
setSelectedFile(java.io.File) if isMultiSelectionEnabled()
return false.
selectedFiles - the current selected filesgetSelectedFiles()public void setRootFile(File rootFile)
JDirChooser root directory, the default is
desktop in windows.
rootFile - the root directorygetRootFile()public File getRootFile()
setRootFile(java.io.File)public void setFileSystemView(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 FileSystemView getFileSystemView()
FileSystemView objectsetFileSystemView(javax.swing.filechooser.FileSystemView)public void setFileView(FileView fileView)
getFileView()public 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:
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(FileFilter fileFilter)
filter - the new current file filter to usegetFileFilter()public FileFilter getFileFilter()
setFileFilter(javax.swing.filechooser.FileFilter)public void ensureFileIsVisible(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(File f)
f - the file that need check
public void refresh()
JDirChooser, this will reload the
file object from file system.
public void refresh(File dir)
dir - the specify directory to refreshpublic void newFolder()
public int showDialog(Component parent)
JDirChooser and
parented to parent with the dialog having a default
title.
parent - the parent of the dialog
showDialog(java.awt.Component)
public int showDialog(Component parent,
String msg,
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 dialog
showDialog(java.awt.Component)
public int showDialog(Component parent,
String msg,
Icon icon,
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 dialog
showDialog(java.awt.Component)
protected JDialog createDialog(Component parent,
String msg,
Icon icon,
String title,
JDirChooser dirChooser,
ActionListener okListener,
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 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 JComponentJDirChooserpublic AccessibleContext getAccessibleContext()
getAccessibleContext in interface AccessiblegetAccessibleContext in class JComponent
|
JComponentPack 1.5.0 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||