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
Modifier and TypeFieldDescriptionstatic final String
"all files" item in the file filter combo boxstatic final int
Whether 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 int
Whether to select files, directories or both (used when common file dialogs are enabled on Windows, or on macOS)static final int
Whether to select files, directories or both (used when common file dialogs are enabled on Windows, or on macOS) -
Method Summary
Modifier and TypeMethodDescriptionstatic JBRFileDialog
get
(FileDialog dialog) GetJBRFileDialog
fromFileDialog
, if supported.int
getHints()
Retrieve extended hints set on file dialog.void
setFileFilterExtensions
(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).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)void
setLocalizationString
(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
GetJBRFileDialog
fromFileDialog
, 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
-