Extensions to the AWT
FileDialog that allow clients fully use a native file chooser
on supported platforms (currently macOS and Windows; the latter requires setting
sun.awt.windows.useCommonItemDialog property to true).-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String"all files" item in the file filter combo boxstatic final intWhether to allow creating directories or not (used on macOS)static final String"open" button when a directory is selected in the liststatic final String"open" button when a file is selected in the liststatic final intWhether to select files, directories or both (used when common file dialogs are enabled on Windows, or on macOS)static final intWhether to select files, directories or both (used when common file dialogs are enabled on Windows, or on macOS) -
Method Summary
Modifier and TypeMethodDescriptionstatic JBRFileDialogget(FileDialog dialog) GetJBRFileDialogfromFileDialog, if supported.intgetHints()Retrieve extended hints set on file dialog.voidsetFileFilterExtensions(String fileFilterDescription, String[] fileFilterExtensions) Set file filter - a set of file extensions for files to be visible (Windows) or not greyed out (macOS), and a name for the file filter combo box (Windows).voidsetHints(int hints) Set file dialog hints: SELECT_FILES_HINT, SELECT_DIRECTORIES_HINT - whether to select files, directories, or both; if neither of the two is set, the behavior is platform-specific CREATE_DIRECTORIES_HINT - whether to allow creating directories or not (macOS)voidsetLocalizationString(String key, String text) Change text of UI elements (Windows).
-
Field Details
-
SELECT_FILES_HINT
static final int SELECT_FILES_HINTWhether to select files, directories or both (used when common file dialogs are enabled on Windows, or on macOS)- See Also:
-
SELECT_DIRECTORIES_HINT
static final int SELECT_DIRECTORIES_HINTWhether to select files, directories or both (used when common file dialogs are enabled on Windows, or on macOS)- See Also:
-
CREATE_DIRECTORIES_HINT
static final int CREATE_DIRECTORIES_HINTWhether to allow creating directories or not (used on macOS)- See Also:
-
OPEN_FILE_BUTTON_KEY
"open" button when a file is selected in the list- See Also:
-
OPEN_DIRECTORY_BUTTON_KEY
"open" button when a directory is selected in the list- See Also:
-
ALL_FILES_COMBO_KEY
"all files" item in the file filter combo box- See Also:
-
-
Method Details
-
get
GetJBRFileDialogfromFileDialog, if supported.- Parameters:
dialog- file dialog- Returns:
- file dialog extension, or null
-
setHints
void setHints(int hints) Set file dialog hints:- SELECT_FILES_HINT, SELECT_DIRECTORIES_HINT - whether to select files, directories, or both; if neither of the two is set, the behavior is platform-specific
- CREATE_DIRECTORIES_HINT - whether to allow creating directories or not (macOS)
- Parameters:
hints- bitmask of selected hints
-
getHints
int getHints()Retrieve extended hints set on file dialog.- Returns:
- bitmask of selected hints
- See Also:
-
setLocalizationString
Change text of UI elements (Windows). Supported keys:- OPEN_FILE_BUTTON_KEY - "open" button when a file is selected in the list
- OPEN_DIRECTORY_BUTTON_KEY - "open" button when a directory is selected in the list
- ALL_FILES_COMBO_KEY - "all files" item in the file filter combo box
- Parameters:
key- keytext- localized text
-
setFileFilterExtensions
Set file filter - a set of file extensions for files to be visible (Windows) or not greyed out (macOS), and a name for the file filter combo box (Windows).- Parameters:
fileFilterDescription- file filter descriptionfileFilterExtensions- file filter extensions
-