Class SwingFileChooser
java.lang.Object
org.openstreetmap.josm.gui.widgets.AbstractFileChooser
org.openstreetmap.josm.gui.widgets.SwingFileChooser
File chooser based on the Swing's
JFileChooser implementation.- Since:
- 7578
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final JFileChooserThe JFileChooser which we use for this.Fields inherited from class org.openstreetmap.josm.gui.widgets.AbstractFileChooser
locale -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddChoosableFileFilter(FileFilter filter) Adds a filter to the list of user choosable file filters.Gets the list of action names.Gets the list of user choosable file filters.Returns the current directory.Returns the currently selected file filter.Returns the selected file.File[]Returns a list of selected files if the file chooser is set to allow multiple selection.booleanReturns true if multiple files can be selected.voidsetAcceptAllFileFilterUsed(boolean b) Determines whether theAcceptAll FileFilteris used as an available choice in the choosable filter list.voidSets the current directory.voidsetDialogTitle(String title) Sets the string that goes in theJFileChooserwindow's title bar.voidsetFileFilter(FileFilter cff) Sets the current file filter.voidsetFileSelectionMode(int selectionMode) Sets theJFileChooserto allow the user to just select files, just select directories, or select both files and directories.voidsetMultiSelectionEnabled(boolean multiple) Sets the file chooser to allow multiple file selections.voidsetSelectedFile(File file) Sets the selected file.intshowOpenDialog(Component parent) Pops up an "Open File" file chooser dialog.intshowSaveDialog(Component parent) Pops up a "Save File" file chooser dialog.Methods inherited from class org.openstreetmap.josm.gui.widgets.AbstractFileChooser
setDefaultLocale
-
Field Details
-
jFileChooser
The JFileChooser which we use for this.
-
-
Constructor Details
-
SwingFileChooser
Constructs a newSwingFileChooser.- Parameters:
file- the current file/directory to point to
-
-
Method Details
-
addChoosableFileFilter
Description copied from class:AbstractFileChooserAdds a filter to the list of user choosable file filters. For information on setting the file selection mode, seesetFileSelectionMode.- Specified by:
addChoosableFileFilterin classAbstractFileChooser- Parameters:
filter- theFileFilterto add to the choosable file filter list- See Also:
-
getChoosableFileFilters
Description copied from class:AbstractFileChooserGets the list of user choosable file filters.- Specified by:
getChoosableFileFiltersin classAbstractFileChooser- Returns:
- a
FileFilterarray containing all the choosable file filters - See Also:
-
getCurrentDirectory
Description copied from class:AbstractFileChooserReturns the current directory.- Specified by:
getCurrentDirectoryin classAbstractFileChooser- Returns:
- the current directory
- See Also:
-
getFileFilter
Description copied from class:AbstractFileChooserReturns the currently selected file filter.- Specified by:
getFileFilterin classAbstractFileChooser- Returns:
- the current file filter
- See Also:
-
getSelectedFile
Description copied from class:AbstractFileChooserReturns the selected file. This can be set either by the programmer viasetSelectedFileor by a user action, such as either typing the filename into the UI or selecting the file from a list in the UI.- Specified by:
getSelectedFilein classAbstractFileChooser- Returns:
- the selected file
- See Also:
-
getSelectedFiles
Description copied from class:AbstractFileChooserReturns a list of selected files if the file chooser is set to allow multiple selection.- Specified by:
getSelectedFilesin classAbstractFileChooser- Returns:
- an array of selected files if the file chooser is set to allow multiple selection, or an empty array otherwise.
-
isMultiSelectionEnabled
Description copied from class:AbstractFileChooserReturns true if multiple files can be selected.- Specified by:
isMultiSelectionEnabledin classAbstractFileChooser- Returns:
- true if multiple files can be selected
- See Also:
-
setAcceptAllFileFilterUsed
Description copied from class:AbstractFileChooserDetermines whether theAcceptAll FileFilteris used as an available choice in the choosable filter list. If false, theAcceptAllfile filter is removed from the list of available file filters. If true, theAcceptAllfile filter will become the actively used file filter.- Specified by:
setAcceptAllFileFilterUsedin classAbstractFileChooser- Parameters:
b- whether theAcceptAll FileFilteris used as an available choice in the choosable filter list- See Also:
-
setCurrentDirectory
Description copied from class:AbstractFileChooserSets the current directory. Passing innullsets 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 ascurrentDirectoryis 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.- Specified by:
setCurrentDirectoryin classAbstractFileChooser- Parameters:
f- the current directory to point to- See Also:
-
setDialogTitle
Description copied from class:AbstractFileChooserSets the string that goes in theJFileChooserwindow's title bar.- Specified by:
setDialogTitlein classAbstractFileChooser- Parameters:
title- the newStringfor the title bar
-
setFileFilter
Description copied from class:AbstractFileChooserSets the current file filter. The file filter is used by the file chooser to filter out files from the user's view.- Specified by:
setFileFilterin classAbstractFileChooser- Parameters:
cff- the new current file filter to use- See Also:
-
setFileSelectionMode
Description copied from class:AbstractFileChooserSets theJFileChooserto allow the user to just select files, just select directories, or select both files and directories. The default isJFilesChooser.FILES_ONLY.- Specified by:
setFileSelectionModein classAbstractFileChooser- Parameters:
selectionMode- the type of files to be displayed:- JFileChooser.FILES_ONLY
- JFileChooser.DIRECTORIES_ONLY
- JFileChooser.FILES_AND_DIRECTORIES
-
setMultiSelectionEnabled
Description copied from class:AbstractFileChooserSets the file chooser to allow multiple file selections.- Specified by:
setMultiSelectionEnabledin classAbstractFileChooser- Parameters:
multiple- true if multiple files may be selected- See Also:
-
setSelectedFile
Description copied from class:AbstractFileChooserSets the selected file. If the file's parent directory is not the current directory, changes the current directory to be the file's parent directory.- Specified by:
setSelectedFilein classAbstractFileChooser- Parameters:
file- the selected file- See Also:
-
showOpenDialog
Description copied from class:AbstractFileChooserPops up an "Open File" file chooser dialog. Note that the text that appears in the approve button is determined by the L&F.- Specified by:
showOpenDialogin classAbstractFileChooser- Parameters:
parent- the parent component of the dialog, can benull; seeshowDialogfor details- Returns:
- the return state of the file chooser on popdown:
- JFileChooser.CANCEL_OPTION
- JFileChooser.APPROVE_OPTION
- JFileChooser.ERROR_OPTION if an error occurs or the dialog is dismissed
- See Also:
-
showSaveDialog
Description copied from class:AbstractFileChooserPops up a "Save File" file chooser dialog. Note that the text that appears in the approve button is determined by the L&F.- Specified by:
showSaveDialogin classAbstractFileChooser- Parameters:
parent- the parent component of the dialog, can benull; seeshowDialogfor details- Returns:
- the return state of the file chooser on popdown:
- JFileChooser.CANCEL_OPTION
- JFileChooser.APPROVE_OPTION
- JFileChooser.ERROR_OPTION if an error occurs or the dialog is dismissed
- See Also:
-
getActionMap
Description copied from class:AbstractFileChooserGets the list of action names.- Specified by:
getActionMapin classAbstractFileChooser- Returns:
- a
ActionMaparray containing all the action names
-