public class JFileSelector extends JPanel
JPanel.AccessibleJPanel
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
protected static UnsortableFileChooser |
chooser |
protected FileSelectorRenderer |
fileRenderer
The file renderer.
|
protected String |
title
The Dialog title.
|
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
JFileSelector()
Create a new FileSelector, without defining a FileChooser name.
|
JFileSelector(String title)
Create a new FileSelector.
|
Modifier and Type | Method and Description |
---|---|
void |
addActionListener(ActionListener listener)
Add an ActionListener.
|
void |
addChoosableFileFilter(FileFilter filter)
Add a Filefilter to this FileSelector.
|
void |
doLayout() |
File |
getCurrentDirectory()
Return the current Directory of this FileSelector.
|
String |
getDialogTitle()
Return the dialog title.
|
int |
getDialogType()
Return the type of this dialog.
|
boolean |
getDragEnabled()
Return true if drag is enabled.
|
static JFileChooser |
getFileChooser()
Return the fileChooser shared by all the instances of the fileSelector.
|
FileFilter |
getFileFilter()
Return the currently selected FileFilter.
|
String |
getFileName()
Return the associated selected File name.
|
String |
getFilePath()
Return the associated selected File path.
|
int |
getFileSelectionMode()
Return the associated FileChooser file selection mode.
|
FileSelectorRenderer |
getFileSelectorRenderer()
Return the class responsible to render to text associated to the selected files.
|
String |
getName()
Return the associated selected File name.
|
Dimension |
getPreferredSize() |
File |
getSelectedFile()
Return the selected File.
|
File[] |
getSelectedFiles()
Return the selected files.
|
FileFilter |
getSpecifiedFileFilter()
Return the specified FileFilter.
|
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 |
isDefaultSorted()
Return true if the File Chooser use the default sorting of the JDK (alphabetical order).
|
boolean |
isEditable()
Return true if the File Selector is editable.
|
boolean |
isEnabled()
Return true if the File Selector is enabled.
|
boolean |
isForcingFileExtension()
Return true if the file extension is forced.
|
boolean |
isUnselected()
Return true for a selection which unselected the file.
|
static void |
main(String[] arg) |
void |
removeActionListener(ActionListener listener)
Removes an ActionListener.
|
void |
removeChoosableFileFilter(FileFilter filter)
Remove a Filefilter to this FileSelector.
|
void |
setBackground(Color color)
Set the background Color of this FileSelector.
|
void |
setChoosableFileFilters(List<FileFilter> filters)
Set the Filefilters for this FileSelector.
|
void |
setChoosableFileFilters(String filters)
Set the Filefilters for this FileSelector.
|
boolean |
setCurrentDirectory(File f)
Set the current Directory of this FileSelector.
|
void |
setDefaultSorted(boolean isDefaultSorted)
Set if the File Chooser use the default sorting of the JDK (alphabetical order), or if the sorting is the order of file selection in the chooser.
|
void |
setDialogTitle(String title)
Set the dialog title.
|
void |
setDialogType(int dialogType)
Set the type of this dialog.
|
void |
setDragEnabled(boolean b)
Set if the drag is enabled.
|
void |
setEditable(boolean b)
Set if the component is editable.
|
void |
setEnabled(boolean b)
Enables or disables this component, depending on the value of the parameter b.
|
void |
setFileFilter(FileFilter filter)
Set the FileFilter to use for the selection.
|
void |
setFileSelectionMode(int mode)
Set the associated FileChooser file selection mode.
|
void |
setFileSelectorRenderer(FileSelectorRenderer fileRenderer)
Set the class responsible to render to text associated to the selected files.
|
void |
setForceFileExtension(boolean forceFileExtension)
Set if the file extension is forced.
|
void |
setHasOptionalFiles(boolean hasOptionalFiles)
Set if the dialog support optional files.
|
void |
setMultiSelectionEnabled(boolean b)
Enable or disable the associated FileChooser multiSelection.
|
void |
setSelectedFile(File f)
Set the current selected File of this FileSelector.
|
void |
setSelectedFiles(File[] f)
Set the current selected Files of this FileSelector.
|
protected void |
setTextAfterFileSelection(String text)
Set the text to show after the files selection.
|
void |
setTransfertHandler(TransferHandler handler)
Set the associated TransferHandler.
|
void |
setUnselectFileText(String unselectFileText)
Set the text to show on the button for the "Unselect file" option.
|
String |
toString() |
void |
updateUI() |
getAccessibleContext, getUI, getUIClassID, paramString, setUI
addAncestorListener, 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, 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, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, 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, validateTree
action, 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, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, 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, transferFocus, transferFocusBackward, transferFocusUpCycle
protected static volatile UnsortableFileChooser chooser
protected String title
protected FileSelectorRenderer fileRenderer
public JFileSelector()
public JFileSelector(String title)
title
- the FileChooser titlepublic void setForceFileExtension(boolean forceFileExtension)
forceFileExtension
- true if the file extension is forcedpublic boolean isForcingFileExtension()
public void setHasOptionalFiles(boolean hasOptionalFiles)
hasOptionalFiles
- true if the dialog support optional filespublic boolean hasOptionalFiles()
public void setUnselectFileText(String unselectFileText)
unselectFileText
- the textpublic String getUnselectFileText()
public static JFileChooser getFileChooser()
public void setDialogTitle(String title)
title
- the titlepublic String getDialogTitle()
public void setFileSelectorRenderer(FileSelectorRenderer fileRenderer)
DefaultFileSelectorRenderer
if the method argument is null.fileRenderer
- the file Rendererpublic FileSelectorRenderer getFileSelectorRenderer()
public void setDefaultSorted(boolean isDefaultSorted)
isDefaultSorted
- true if the File Chooser use the default sorting of the JDK (alphabetical order)public boolean isDefaultSorted()
public int getFileSelectionMode()
JFileChooser.getFileSelectionMode()
public void setDragEnabled(boolean b)
b
- true if the drag is enabledpublic void setFileFilter(FileFilter filter)
filter
- the selected FileFilterpublic FileFilter getFileFilter()
public FileFilter getSpecifiedFileFilter()
public void setTransfertHandler(TransferHandler handler)
handler
- the associated TransferHandlerpublic boolean getDragEnabled()
public void setDialogType(int dialogType)
dialogType
- the type of this dialogpublic int getDialogType()
public void setFileSelectionMode(int mode)
mode
- the associated FileChooser file selection modeJFileChooser.setFileSelectionMode(int)
public void setMultiSelectionEnabled(boolean b)
b
- true if the associated FileChooser multiSelection is enabledJFileChooser.setMultiSelectionEnabled(boolean)
public File getSelectedFile()
public File[] getSelectedFiles()
public void setChoosableFileFilters(String filters)
setChoosableFileFilters(java.util.List)
method.
The format of the argument is:
extension1,extension2,...,extension-n;
filters
- the Filefilterspublic void setChoosableFileFilters(List<FileFilter> filters)
filters
- the Filefilterspublic void addChoosableFileFilter(FileFilter filter)
filter
- the Filefilterpublic void removeChoosableFileFilter(FileFilter filter)
filter
- the Filefilterpublic void addActionListener(ActionListener listener)
listener
- the ActionListenerpublic void removeActionListener(ActionListener listener)
listener
- the ActionListenerpublic String getFileName()
public String getFilePath()
public String getName()
protected final void setTextAfterFileSelection(String text)
text
- the text to showpublic Dimension getPreferredSize()
getPreferredSize
in class JComponent
public void setBackground(Color color)
setBackground
in class JComponent
color
- the background Color of this FileSelectorpublic boolean setCurrentDirectory(File f)
f
- the current Directory to setpublic File getCurrentDirectory()
public void setSelectedFile(File f)
f
- the current selected File of this FileSelectorpublic void setSelectedFiles(File[] f)
f
- the current selected Files of this FileSelectorpublic void setEditable(boolean b)
b
- true if the component is editablepublic void setEnabled(boolean b)
setEnabled
in class JComponent
b
- true if the dialog is enabledpublic boolean isEditable()
public boolean isEnabled()
public boolean isUnselected()
public static void main(String[] arg)