public class NativeFileChooser extends AbstractFileChooser
FileDialog implementation,
which looks like more a native file chooser than the Swing implementation.| Modifier and Type | Field and Description |
|---|---|
private java.awt.FileDialog |
fileDialog
The instance of the fileDialog
|
private javax.swing.filechooser.FileFilter |
fileFilter |
private java.util.List<javax.swing.filechooser.FileFilter> |
fileFilters |
private int |
selectionMode |
locale| Constructor and Description |
|---|
NativeFileChooser(java.io.File file)
Constructs a new
NativeFileChooser. |
| Modifier and Type | Method and Description |
|---|---|
void |
addChoosableFileFilter(javax.swing.filechooser.FileFilter filter)
Adds a filter to the list of user choosable file filters.
|
javax.swing.filechooser.FileFilter[] |
getChoosableFileFilters()
Gets the list of user choosable file filters.
|
java.io.File |
getCurrentDirectory()
Returns the current directory.
|
javax.swing.filechooser.FileFilter |
getFileFilter()
Returns the currently selected file filter.
|
java.io.File |
getSelectedFile()
Returns the selected file.
|
java.io.File[] |
getSelectedFiles()
Returns a list of selected files if the file chooser is
set to allow multiple selection.
|
boolean |
isMultiSelectionEnabled()
Returns true if multiple files can be selected.
|
void |
setAcceptAllFileFilterUsed(boolean b)
Determines whether the
AcceptAll FileFilter is used
as an available choice in the choosable filter list. |
void |
setCurrentDirectory(java.io.File f)
Sets the current directory.
|
void |
setDialogTitle(java.lang.String title)
Sets the string that goes in the
JFileChooser window's
title bar. |
void |
setFileFilter(javax.swing.filechooser.FileFilter cff)
Sets the current file filter.
|
void |
setFileSelectionMode(int selectionMode)
Sets the
JFileChooser to allow the user to just
select files, just select
directories, or select both files and directories. |
void |
setMultiSelectionEnabled(boolean multiple)
Sets the file chooser to allow multiple file selections.
|
void |
setSelectedFile(java.io.File file)
Sets the selected file.
|
int |
showOpenDialog(java.awt.Component parent)
Pops up an "Open File" file chooser dialog.
|
int |
showSaveDialog(java.awt.Component parent)
Pops up a "Save File" file chooser dialog.
|
static boolean |
supportsSelectionMode(int selectionMode)
Determines if the selection mode is suuported by the native file chooser.
|
setDefaultLocaleprivate final java.awt.FileDialog fileDialog
private javax.swing.filechooser.FileFilter fileFilter
private final java.util.List<javax.swing.filechooser.FileFilter> fileFilters
private int selectionMode
public NativeFileChooser(java.io.File file)
NativeFileChooser.file - the current file/directory to point topublic void addChoosableFileFilter(javax.swing.filechooser.FileFilter filter)
AbstractFileChoosersetFileSelectionMode.addChoosableFileFilter in class AbstractFileChooserfilter - the FileFilter to add to the choosable file
filter listAbstractFileChooser.getChoosableFileFilters(),
AbstractFileChooser.setFileSelectionMode(int)public javax.swing.filechooser.FileFilter[] getChoosableFileFilters()
AbstractFileChoosergetChoosableFileFilters in class AbstractFileChooserFileFilter array containing all the choosable
file filtersAbstractFileChooser.addChoosableFileFilter(javax.swing.filechooser.FileFilter)public java.io.File getCurrentDirectory()
AbstractFileChoosergetCurrentDirectory in class AbstractFileChooserAbstractFileChooser.setCurrentDirectory(java.io.File)public javax.swing.filechooser.FileFilter getFileFilter()
AbstractFileChoosergetFileFilter in class AbstractFileChooserAbstractFileChooser.setFileFilter(javax.swing.filechooser.FileFilter),
AbstractFileChooser.addChoosableFileFilter(javax.swing.filechooser.FileFilter)public java.io.File getSelectedFile()
AbstractFileChoosersetSelectedFile or by a user action, such as
either typing the filename into the UI or selecting the
file from a list in the UI.getSelectedFile in class AbstractFileChooserAbstractFileChooser.setSelectedFile(java.io.File)public java.io.File[] getSelectedFiles()
AbstractFileChoosergetSelectedFiles in class AbstractFileChooserpublic boolean isMultiSelectionEnabled()
AbstractFileChooserisMultiSelectionEnabled in class AbstractFileChooserAbstractFileChooser.setMultiSelectionEnabled(boolean)public void setAcceptAllFileFilterUsed(boolean b)
AbstractFileChooserAcceptAll FileFilter is used
as an available choice in the choosable filter list.
If false, the AcceptAll file filter is removed from
the list of available file filters.
If true, the AcceptAll file filter will become the
the actively used file filter.setAcceptAllFileFilterUsed in class AbstractFileChooserb - whether the AcceptAll FileFilter is used
as an available choice in the choosable filter listAbstractFileChooser.setFileFilter(javax.swing.filechooser.FileFilter)public void setCurrentDirectory(java.io.File f)
AbstractFileChoosernull sets the
file chooser to point to the user's default directory.
This default depends on the operating system. It is
typically the "My Documents" folder on Windows, and the user's
home directory on Unix.
If the file passed in as currentDirectory is not a
directory, the parent of the file will be used as the currentDirectory.
If the parent is not traversable, then it will walk up the parent tree
until it finds a traversable directory, or hits the root of the
file system.setCurrentDirectory in class AbstractFileChooserf - the current directory to point toAbstractFileChooser.getCurrentDirectory()public void setDialogTitle(java.lang.String title)
AbstractFileChooserJFileChooser window's
title bar.setDialogTitle in class AbstractFileChoosertitle - the new String for the title barpublic void setFileFilter(javax.swing.filechooser.FileFilter cff)
AbstractFileChoosersetFileFilter in class AbstractFileChoosercff - the new current file filter to useAbstractFileChooser.getFileFilter()public void setFileSelectionMode(int selectionMode)
AbstractFileChooserJFileChooser to allow the user to just
select files, just select
directories, or select both files and directories. The default is
JFilesChooser.FILES_ONLY.setFileSelectionMode in class AbstractFileChooserselectionMode - the type of files to be displayed:
public void setMultiSelectionEnabled(boolean multiple)
AbstractFileChoosersetMultiSelectionEnabled in class AbstractFileChoosermultiple - true if multiple files may be selectedAbstractFileChooser.isMultiSelectionEnabled()public void setSelectedFile(java.io.File file)
AbstractFileChoosersetSelectedFile in class AbstractFileChooserfile - the selected fileAbstractFileChooser.getSelectedFile()public int showOpenDialog(java.awt.Component parent)
AbstractFileChoosershowOpenDialog in class AbstractFileChooserparent - the parent component of the dialog,
can be null;
see showDialog for detailsGraphicsEnvironment.isHeadless()public int showSaveDialog(java.awt.Component parent)
AbstractFileChoosershowSaveDialog in class AbstractFileChooserparent - the parent component of the dialog,
can be null;
see showDialog for detailsGraphicsEnvironment.isHeadless()public static boolean supportsSelectionMode(int selectionMode)
selectionMode - the selection modetrue if the selection mode is supported, false otherwise