public class AJFileChooser
extends javax.swing.JFileChooser
| Modifier and Type | Class and Description |
|---|---|
static class |
AJFileChooser.DefaultDeleter
DefaultDeleter is the default implementation of
Deleter abstract class. |
static class |
AJFileChooser.Deleter
Deleter abstract class allows AJFileChooser
to perform delete operations. |
static class |
AJFileChooser.ExtensionFileFilter
ExtensionFileFilter accepts files with the one of the given extensions
and also any traversable nodes - subdirectories, links, network places, etc. |
static interface |
AJFileChooser.FileNameFilter |
protected static class |
AJFileChooser.SpecialFilesListKeyListener |
protected static class |
AJFileChooser.SpecialGoHomeActionListener |
static class |
AJFileChooser.SubdirectoryFilter
SubdirectoryFilter should be set by the same setFileFilter() method. |
static class |
AJFileChooser.WhereToAddButtons |
javax.swing.JFileChooser.AccessibleJFileChooserjavax.swing.JComponent.AccessibleJComponent| Modifier and Type | Field and Description |
|---|---|
protected boolean |
approveButtonShouldBeDefault |
static java.lang.String |
APPROVING_FILES_ONLY_ENABLED_CHANGED_PROPERTY
Identifies a change in the approvingFilesOnlyEnabled property.
|
static java.lang.String |
APPROVING_NON_EXISTING_FILES_ENABLED_CHANGED_PROPERTY
Identifies a change in the approvingNonExistingFilesEnabled property.
|
protected java.util.List |
deleteButtons |
static java.lang.String |
DELETER_CHANGED_PROPERTY
Identifies a change in the deleter property.
|
static java.lang.String |
OVERWRITE_WARNING_ENABLED_CHANGED_PROPERTY
Identifies a change in the overwriteWarningEnabled property.
|
static java.lang.String |
TRAVERSING_LINKS_ENABLED_CHANGED_PROPERTY
Identifies a change in the traversingLinksEnabled property.
|
ACCEPT_ALL_FILE_FILTER_USED_CHANGED_PROPERTY, accessibleContext, ACCESSORY_CHANGED_PROPERTY, APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY, APPROVE_BUTTON_TEXT_CHANGED_PROPERTY, APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY, APPROVE_OPTION, APPROVE_SELECTION, CANCEL_OPTION, CANCEL_SELECTION, CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY, CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY, CUSTOM_DIALOG, DIALOG_TITLE_CHANGED_PROPERTY, DIALOG_TYPE_CHANGED_PROPERTY, DIRECTORIES_ONLY, DIRECTORY_CHANGED_PROPERTY, ERROR_OPTION, FILE_FILTER_CHANGED_PROPERTY, FILE_HIDING_CHANGED_PROPERTY, FILE_SELECTION_MODE_CHANGED_PROPERTY, FILE_SYSTEM_VIEW_CHANGED_PROPERTY, FILE_VIEW_CHANGED_PROPERTY, FILES_AND_DIRECTORIES, FILES_ONLY, MULTI_SELECTION_ENABLED_CHANGED_PROPERTY, OPEN_DIALOG, SAVE_DIALOG, SELECTED_FILE_CHANGED_PROPERTY, SELECTED_FILES_CHANGED_PROPERTYlistenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW| Constructor and Description |
|---|
AJFileChooser() |
AJFileChooser(java.io.File currentDirectory) |
AJFileChooser(java.io.File currentDirectory,
javax.swing.filechooser.FileSystemView fsv) |
AJFileChooser(javax.swing.filechooser.FileSystemView fsv) |
AJFileChooser(java.lang.String currentDirectoryPath) |
AJFileChooser(java.lang.String currentDirectoryPath,
javax.swing.filechooser.FileSystemView fsv) |
| Modifier and Type | Method and Description |
|---|---|
void |
addDeleteButton(javax.swing.AbstractButton button)
Adds the given button to internal list
deleteButtons
and sets the button's action listener that calls
deleteSelectedFiles() method. |
void |
approveSelection()
Overrided to process special (described above) features of this class.
|
boolean |
canDeleteSelectedFiles()
Returns true if the current
deleter interface says
(by its canDelete method) that all selected files
can be deleted. |
protected javax.swing.JDialog |
createDialog(java.awt.Component parent)
Overrided to provide working of
tryToMakeApproveButtonDefault() method. |
boolean |
deleteSelectedFiles()
Tries to delete all selected files using the method
delete
of the current deleter interface. |
java.io.File |
getCurrentDirectory() |
java.lang.String |
getDefaultApproveButtonText()
Returns the default text of the Approve button.
|
java.lang.String |
getDefaultApproveButtonToolTipText()
Returns the default tooltop text of the Cancel button.
|
java.lang.String |
getDefaultCancelButtonText()
Returns the default text of the Cancel button.
|
java.lang.String |
getDefaultCancelButtonToolTipText()
Returns the default tooltop text of the Cancel button.
|
AJFileChooser.Deleter |
getDeleter()
Returns the value of the
deleter property. |
static java.io.File |
getLinkLocationUndocumented(java.io.File f) |
static int |
indexOfExtension(java.io.File f,
java.lang.String[] extensions)
Checks extension of the file
f and returns
its index in extensions array (-1 if not found). |
boolean |
isApprovingFilesOnlyEnabled()
Returns the value of the
approvingFilesOnlyEnabled
property. |
boolean |
isApprovingNonExistingFilesEnabled()
Returns the value of the
approvingNonExistingFilesEnabled
property. |
static boolean |
isLinkUndocumented(java.io.File f) |
boolean |
isOverwriteWarningEnabled()
Returns the value of the
overwriteWarningEnabled
property. |
boolean |
isTraversable(java.io.File f)
Overrided to process
traversingLinksEnabled property. |
boolean |
isTraversingLinksEnabled()
Returns the value of the
traversingLinksEnabled
property. |
void |
setApprovingFilesOnlyEnabled(boolean b)
Sets the property that indicates whether some folders
(more precisely, traversable elements) can be approved -
regargless of the current file-selection mode.
|
void |
setApprovingNonExistingFilesEnabled(boolean b)
Sets the property that indicates whether the approve
button originates the corresponding APPROVE_SELECTION
action and closes the dialog shown by showXxxDialog method in a case
when the selected file or subdirectory does not exist.
|
void |
setCurrentDirectory(java.io.File f)
Overrided to process
traversingLinksEnabled property. |
void |
setDeleter(AJFileChooser.Deleter deleter)
Installs
deleter - an abstract class allowing
canDeleteSelectedFiles and deleteSelectedFiles
methods to work. |
void |
setFileFilters(javax.swing.filechooser.FileFilter[] filters)
Convenient extension of standard
setFileFilter and
addChoosableFileFilter methods. |
void |
setOverwriteWarningEnabled(boolean b)
Sets the property that indicates whether overwrite warning
is shown when the user tries to approve a file or folder that
already exists.
|
void |
setSelectedFile(java.io.File file) |
void |
setTraversingLinksEnabled(boolean b)
Sets the property that indicates whether links
can be traversable.
|
boolean |
tryToAddButtons(javax.swing.AbstractButton[] buttons,
AJFileChooser.WhereToAddButtons where,
boolean addSpaceAround,
boolean addSpaceBetween)
Should return true if successful.
|
void |
tryToAvoidSlowingProblemInLargeDirectories()
Tries to avoid extra slowing of choosing files in large directories
|
javax.swing.AbstractButton |
tryToFindAndCorrectHomeButton(java.io.File newHomeDirectory)
Should return not null if successful.
|
javax.swing.JList |
tryToFindFilesList()
Should return not null if successful.
|
javax.swing.JList |
tryToFindFilesListAndCorrectKeyboardBug()
Should return not null if successful.
|
javax.swing.AbstractButton |
tryToFindNewFolderButton()
Should return not null if successful.
|
boolean |
tryToMakeApproveButtonDefault()
Should return true if successful.
|
boolean |
tryToRemoveNewFolderButton()
Should return true if successful.
|
boolean |
tryToRemoveSingleClickListeners()
Should return true if successful.
|
accept, addActionListener, addChoosableFileFilter, cancelSelection, changeToParentDirectory, ensureFileIsVisible, fireActionPerformed, getAcceptAllFileFilter, getAccessibleContext, getAccessory, getActionListeners, getApproveButtonMnemonic, getApproveButtonText, getApproveButtonToolTipText, getChoosableFileFilters, getControlButtonsAreShown, getDescription, getDialogTitle, getDialogType, getDragEnabled, getFileFilter, getFileSelectionMode, getFileSystemView, getFileView, getIcon, getName, getSelectedFile, getSelectedFiles, getTypeDescription, getUI, getUIClassID, isAcceptAllFileFilterUsed, isDirectorySelectionEnabled, isFileHidingEnabled, isFileSelectionEnabled, isMultiSelectionEnabled, paramString, removeActionListener, removeChoosableFileFilter, rescanCurrentDirectory, resetChoosableFileFilters, setAcceptAllFileFilterUsed, setAccessory, setApproveButtonMnemonic, setApproveButtonMnemonic, setApproveButtonText, setApproveButtonToolTipText, setControlButtonsAreShown, setDialogTitle, setDialogType, setDragEnabled, setFileFilter, setFileHidingEnabled, setFileSelectionMode, setFileSystemView, setFileView, setMultiSelectionEnabled, setSelectedFiles, setup, showDialog, showOpenDialog, showSaveDialog, updateUIaddAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateadd, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCyclepublic static final java.lang.String APPROVING_NON_EXISTING_FILES_ENABLED_CHANGED_PROPERTY
public static final java.lang.String OVERWRITE_WARNING_ENABLED_CHANGED_PROPERTY
public static final java.lang.String APPROVING_FILES_ONLY_ENABLED_CHANGED_PROPERTY
public static final java.lang.String TRAVERSING_LINKS_ENABLED_CHANGED_PROPERTY
public static final java.lang.String DELETER_CHANGED_PROPERTY
protected java.util.List deleteButtons
protected boolean approveButtonShouldBeDefault
public AJFileChooser()
public AJFileChooser(java.lang.String currentDirectoryPath)
public AJFileChooser(java.io.File currentDirectory)
public AJFileChooser(javax.swing.filechooser.FileSystemView fsv)
public AJFileChooser(java.io.File currentDirectory,
javax.swing.filechooser.FileSystemView fsv)
public AJFileChooser(java.lang.String currentDirectoryPath,
javax.swing.filechooser.FileSystemView fsv)
public java.lang.String getDefaultApproveButtonText()
getApproveButtonText returns null.
Typically, this would be "Open" or "Save".JFileChooser.getApproveButtonText()public java.lang.String getDefaultApproveButtonToolTipText()
getApproveButtonToolTipText returns null.
Typically, this would be "Cancel".JFileChooser.getApproveButtonToolTipText()public java.lang.String getDefaultCancelButtonText()
JFileChooser.getApproveButtonText()public java.lang.String getDefaultCancelButtonToolTipText()
JFileChooser.getApproveButtonToolTipText()public boolean isApprovingNonExistingFilesEnabled()
approvingNonExistingFilesEnabled
property.approvingNonExistingFilesEnabled
property
#setApprovingNonExistingFilesEnabledpublic void setApprovingNonExistingFilesEnabled(boolean b)
Default value for this property is true (that corresponds to the standard behaviour).
This property has no effect in the Save dialogs or when multiple file selections are allowed.
This method fires a property-changed event, using the string
value of APPROVING_NON_EXISTING_FILES_ENABLED_CHANGED_PROPERTY
as the name of the property.
b - true if non-existing files should be approved;
false it you want to disable approving non-existing filesisApprovingNonExistingFilesEnabled(),
APPROVING_NON_EXISTING_FILES_ENABLED_CHANGED_PROPERTYpublic boolean isOverwriteWarningEnabled()
overwriteWarningEnabled
property.overwriteWarningEnabled
property
#setOverwriteWarningEnabledpublic void setOverwriteWarningEnabled(boolean b)
Default value for this property is false (that corresponds to the standard behaviour).
This property has no effect in the Open dialogs or when multiple file selections are allowed.
This method fires a property-changed event, using the string
value of OVERWRITE_WARNING_ENABLED_CHANGED_PROPERTY
as the name of the property.
b - true if Approve button should lead to
showing overwrite warning when an existing file or directory
is selected;
false if existing files can be approved without
warning.isOverwriteWarningEnabled(),
OVERWRITE_WARNING_ENABLED_CHANGED_PROPERTYpublic boolean isApprovingFilesOnlyEnabled()
approvingFilesOnlyEnabled
property.approvingFilesOnlyEnabled
property
#setApprovingFilesOnlyEnabledpublic void setApprovingFilesOnlyEnabled(boolean b)
getSelectedFile()
method.
Default value for this property is false (that corresponds to the standard behaviour).
This method fires a property-changed event, using the string
value of APPROVING_FILES_ONLY_ENABLED_CHANGED_PROPERTY
as the name of the property.
b - true if traversable elements should
be never approvedisApprovingFilesOnlyEnabled(),
APPROVING_FILES_ONLY_ENABLED_CHANGED_PROPERTYpublic boolean isTraversingLinksEnabled()
traversingLinksEnabled
property.traversingLinksEnabled
property
#setTraversingLinksEnabledpublic void setTraversingLinksEnabled(boolean b)
Default value for this property is false (that corresponds to the standard behaviour).
This method fires a property-changed event, using the string
value of TRAVERSING_LINKS_ENABLED_CHANGED_PROPERTY
as the name of the property.
b - true if links should be processed
correctly;
false if links should be processed as
usual files.isTraversingLinksEnabled(),
TRAVERSING_LINKS_ENABLED_CHANGED_PROPERTYpublic AJFileChooser.Deleter getDeleter()
deleter property.public void setDeleter(AJFileChooser.Deleter deleter)
deleter - an abstract class allowing
canDeleteSelectedFiles and deleteSelectedFiles
methods to work.
To make delete operations availavle to the user, you also should
add some buttons that call canDeleteSelectedFiles and
deleteSelectedFiles methods - for example, by means
of tryToAddButtons method.
Warning: if you want to delete not only files, but also subdirectories,
you should not use FILES_ONLY file-selection mode. If you need to provide
usual behaviour of Approve button for folders - opening the
selected folder - please use approvingFilesOnlyEnabled
property.
This method fires a property-changed event, using the string
value of DELETER_CHANGED_PROPERTY
as the name of the property.
deleter - New instance of AJFileChooser.Deleter abstract class.
Can be null - then the current deleter will be removed.getDeleter(),
isApprovingFilesOnlyEnabled(),
setApprovingFilesOnlyEnabled(boolean),
tryToAddButtons(javax.swing.AbstractButton[], net.algart.swing.AJFileChooser.WhereToAddButtons, boolean, boolean),
DELETER_CHANGED_PROPERTYpublic void setFileFilters(javax.swing.filechooser.FileFilter[] filters)
setFileFilter and
addChoosableFileFilter methods.
The methods resets the choosable file filter list (by
resetChoosableFileFilters() method), and adds
all given filters. If the current selected filter
is present in the new filters, it stays current. Else,
if the current selected file matches one of new filters,
the first such filter becomes current. Else,
the first filter (filters[0]) becomes current.
JFileChooser.addChoosableFileFilter(javax.swing.filechooser.FileFilter),
JFileChooser.resetChoosableFileFilters(),
JFileChooser.setFileFilter(javax.swing.filechooser.FileFilter)public static int indexOfExtension(java.io.File f,
java.lang.String[] extensions)
f and returns
its index in extensions array (-1 if not found).
All extensions should be in lower case
(converted by the call ...toUpperCase().toLowerCase()).
Used in the ExtensionFileFilter.accept method.public boolean canDeleteSelectedFiles()
deleter interface says
(by its canDelete method) that all selected files
can be deleted.
Always returns false it the deleter isn't installed.public boolean deleteSelectedFiles()
delete
of the current deleter interface. Does nothing if the deleter
isn't installed. Does nothing if canDeleteSelectedFiles() returns
false.public void addDeleteButton(javax.swing.AbstractButton button)
deleteButtons
and sets the button's action listener that calls
deleteSelectedFiles() method.
AJFileChooser automatically controls the enable/disable status
of the added button.public void approveSelection()
Also, this implementation requires some file to be selected
to perform Approve action. (By default, null
also can be approved.)
approveSelection in class javax.swing.JFileChooserpublic boolean isTraversable(java.io.File f)
traversingLinksEnabled property.isTraversable in class javax.swing.JFileChooserpublic void setCurrentDirectory(java.io.File f)
traversingLinksEnabled property.setCurrentDirectory in class javax.swing.JFileChooserprotected javax.swing.JDialog createDialog(java.awt.Component parent)
tryToMakeApproveButtonDefault() method.createDialog in class javax.swing.JFileChooserpublic void tryToAvoidSlowingProblemInLargeDirectories()
public void setSelectedFile(java.io.File file)
setSelectedFile in class javax.swing.JFileChooserpublic java.io.File getCurrentDirectory()
getCurrentDirectory in class javax.swing.JFileChooserpublic boolean tryToRemoveSingleClickListeners()
public boolean tryToAddButtons(javax.swing.AbstractButton[] buttons,
AJFileChooser.WhereToAddButtons where,
boolean addSpaceAround,
boolean addSpaceBetween)
public javax.swing.AbstractButton tryToFindNewFolderButton()
public boolean tryToRemoveNewFolderButton()
public javax.swing.AbstractButton tryToFindAndCorrectHomeButton(java.io.File newHomeDirectory)
newHomeDirectory - - if not null, Home button will change
the current directory to this onepublic boolean tryToMakeApproveButtonDefault()
showXxxDialog()
methods), this method should be called after adding
AJFileChooser into the container, but not just
after creating AJFileChooser instance.public javax.swing.JList tryToFindFilesList()
public javax.swing.JList tryToFindFilesListAndCorrectKeyboardBug()
public static boolean isLinkUndocumented(java.io.File f)
public static java.io.File getLinkLocationUndocumented(java.io.File f)
throws java.io.FileNotFoundException
java.io.FileNotFoundException