Class ComboFileDialog
java.lang.Object
nl.colorize.util.swing.ComboFileDialog
A wrapper around both AWT's
FileDialog and Swing's
JFileChooser. While the Swing file dialog is superior in
terms of functionality, its appearance can be far from native dialogs on some
platforms. AWT dialogs look like native dialogs, but provide less features.
This class will therefore make the tradeoff which file dialog is best for the
current platform.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a file dialog with the platform's default dialog title and start directory.ComboFileDialog(String title, File start) Creates a file dialog with the specified title and start directory. -
Method Summary
Modifier and TypeMethodDescriptionnl.colorize.util.swing.ComboFileDialog.FileExtFiltergetTitle()voidSets a filter so that the dialog will only show files with the specified file extension(s).voidsetStartDirectory(File start) voidsetStartDirectory(String path) voidshowOpenDialog(JFrame parent) Shows an 'open file' dialog and returns the selected file.showSaveDialog(JFrame parent, String extension) Shows a 'save file' dialog, and returns the selected file.booleanReturns whether file dialogs are created using Swing (if this returns true) or AWT (if this returns false).
-
Field Details
-
bundle
-
-
Constructor Details
-
ComboFileDialog
-
ComboFileDialog
public ComboFileDialog()Creates a file dialog with the platform's default dialog title and start directory.
-
-
Method Details
-
usesSwingDialogs
public boolean usesSwingDialogs()Returns whether file dialogs are created using Swing (if this returns true) or AWT (if this returns false). -
showOpenDialog
-
showSaveDialog
Shows a 'save file' dialog, and returns the selected file. If the selected file already exists, an extra confirmation dialog is shown to make sure the user wants to overwrite the file. Returnsnullif the dialog was cancelled.- Parameters:
parent- The parent window for the dialog.extension- File extension to use if none is entered.
-
setTitle
-
setStartDirectory
-
setStartDirectory
-
setFilter
Sets a filter so that the dialog will only show files with the specified file extension(s).- Parameters:
description- A textual description of the filter.extensions- An array of file name extensions, such as "png", or "jpg".- Throws:
IllegalArgumentException- if the filter has no file extensions.
-
getTitle
-
getStartDirectory
-
getFilter
public nl.colorize.util.swing.ComboFileDialog.FileExtFilter getFilter() -
getBundle
-