public class JOptionalFileChooser extends JFileChooser
JFileChooser.AccessibleJFileChooserJComponent.AccessibleJComponentContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategyACCEPT_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_WINDOWBOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| Constructor and Description |
|---|
JOptionalFileChooser()
Constructor.
|
JOptionalFileChooser(File currentDirectory)
Constructor.
|
JOptionalFileChooser(File currentDirectory,
boolean isRestricted)
Constructor.
|
JOptionalFileChooser(File currentDirectory,
FileSystemView fsv)
Constructor.
|
JOptionalFileChooser(FileSystemView fsv)
Constructor.
|
JOptionalFileChooser(String currentDirectoryPath)
Constructor.
|
JOptionalFileChooser(String currentDirectoryPath,
boolean isRestricted)
Constructor.
|
JOptionalFileChooser(String currentDirectoryPath,
FileSystemView fsv)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
File |
getSelectedFile()
Returns the selected file.
|
File[] |
getSelectedFiles()
Returns a list of selected files if the file chooser is set to allow multiple selection.
|
String |
getUnselectFileText()
Return the text to show on the button for the "Unselect file" option.
|
boolean |
hasOptionalFiles()
Return true if the dialog support optional files.
|
boolean |
isUnselected()
Return true for a selection which unselected the file.
|
static void |
main(String[] args) |
void |
setHasOptionalFiles(boolean hasOptionalFiles)
Set if the dialog support optional files.
|
void |
setUnselectFileText(String unselectFileText)
Set the text to show on the button for the "Unselect file" option.
|
int |
showDialog(Component parent,
String approveButtonText)
Pops a custom file chooser dialog with a custom approve button.
|
int |
showOpenDialog(Component parent)
Pops an Open file chooser dialog with a custom approve button.
|
int |
showSaveDialog(Component parent)
Pops a Save file chooser dialog with a custom approve button.
|
accept, addActionListener, addChoosableFileFilter, approveSelection, cancelSelection, changeToParentDirectory, createDialog, ensureFileIsVisible, fireActionPerformed, getAcceptAllFileFilter, getAccessibleContext, getAccessory, getActionListeners, getApproveButtonMnemonic, getApproveButtonText, getApproveButtonToolTipText, getChoosableFileFilters, getControlButtonsAreShown, getCurrentDirectory, getDescription, getDialogTitle, getDialogType, getDragEnabled, getFileFilter, getFileSelectionMode, getFileSystemView, getFileView, getIcon, getName, getTypeDescription, getUI, getUIClassID, isAcceptAllFileFilterUsed, isDirectorySelectionEnabled, isFileHidingEnabled, isFileSelectionEnabled, isMultiSelectionEnabled, isTraversable, paramString, removeActionListener, removeChoosableFileFilter, rescanCurrentDirectory, resetChoosableFileFilters, setAcceptAllFileFilterUsed, setAccessory, setApproveButtonMnemonic, setApproveButtonMnemonic, setApproveButtonText, setApproveButtonToolTipText, setControlButtonsAreShown, setCurrentDirectory, setDialogTitle, setDialogType, setDragEnabled, setFileFilter, setFileHidingEnabled, setFileSelectionMode, setFileSystemView, setFileView, setMultiSelectionEnabled, setSelectedFile, setSelectedFiles, setup, 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 JOptionalFileChooser()
public JOptionalFileChooser(FileSystemView fsv)
fsv - the file system viewpublic JOptionalFileChooser(File currentDirectory)
currentDirectory - the current directorypublic JOptionalFileChooser(File currentDirectory, FileSystemView fsv)
currentDirectory - the current directoryfsv - the file system viewpublic JOptionalFileChooser(File currentDirectory, boolean isRestricted)
currentDirectory - the current directoryisRestricted - true if the file chooser is restricted to the current directorypublic JOptionalFileChooser(String currentDirectoryPath)
currentDirectoryPath - the current directory pathpublic JOptionalFileChooser(String currentDirectoryPath, FileSystemView fsv)
currentDirectoryPath - the current directory pathfsv - the file system viewpublic JOptionalFileChooser(String currentDirectoryPath, boolean isRestricted)
currentDirectoryPath - the current directory pathisRestricted - true if the file chooser is restricted to the current directorypublic void setHasOptionalFiles(boolean hasOptionalFiles)
hasOptionalFiles - true if the dialog support optional filespublic boolean hasOptionalFiles()
public void setUnselectFileText(String unselectFileText)
unselectFileText - the textpublic int showDialog(Component parent, String approveButtonText) throws HeadlessException
hasOptionalFiles() is true.showDialog in class JFileChooserparent - the parent component of the dialog; can be nullapproveButtonText - the text of the ApproveButtonHeadlessException - if GraphicsEnvironment.isHeadless() returns true.public int showOpenDialog(Component parent) throws HeadlessException
hasOptionalFiles() is true.showOpenDialog in class JFileChooserparent - the parent component of the dialog; can be nullHeadlessException - if GraphicsEnvironment.isHeadless() returns true.public int showSaveDialog(Component parent) throws HeadlessException
hasOptionalFiles() is true.showSaveDialog in class JFileChooserparent - the parent component of the dialog; can be nullHeadlessException - if GraphicsEnvironment.isHeadless() returns true.public String getUnselectFileText()
public File getSelectedFile()
getSelectedFile in class JFileChooserpublic boolean isUnselected()
public File[] getSelectedFiles()
getSelectedFiles in class JFileChooserpublic static void main(String[] args)