Class FlatNativeMacLibrary
java.lang.Object
com.formdev.flatlaf.ui.FlatNativeMacLibrary
Native methods for macOS.
Note: This is private API. Do not use!
Methods that use windows as parameter
For all methods that accept aWindow as parameter,
the underlying macOS window must be already created,
otherwise the method fails. You can use following to ensure this:
if( !window.isDisplayable() )
window.addNotify();
or invoke the method after packing the window. E.g.
window.pack();
- Since:
- 3.3
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic RectanglegetWindowButtonsBounds(Window window) static booleanisLoaded()Checks whether native library is loaded/available.static booleanisWindowFullScreen(Window window) static booleansetWindowButtonsSpacing(Window window, int buttonsSpacing) static booleansetWindowRoundedBorder(Window window, float radius, float borderWidth, int borderColor) static String[]showFileChooser(Window owner, int dark, boolean open, String title, String prompt, String message, String filterFieldLabel, String nameFieldLabel, String nameFieldStringValue, String directoryURL, int optionsSet, int optionsClear, FlatNativeMacLibrary.FileChooserCallback callback, int fileTypeIndex, String[] fileTypes, int[] retFileTypeIndex) Shows the macOS system file dialogs NSOpenPanel or NSSavePanel.static intshowMessageDialog(long hwndParent, int alertStyle, String messageText, String informativeText, int defaultButton, String... buttons) Shows a macOS alert NSAlert.static booleantoggleWindowFullScreen(Window window)
-
Field Details
-
BUTTONS_SPACING_DEFAULT
public static final int BUTTONS_SPACING_DEFAULT- Since:
- 3.4
- See Also:
-
BUTTONS_SPACING_MEDIUM
public static final int BUTTONS_SPACING_MEDIUM- Since:
- 3.4
- See Also:
-
BUTTONS_SPACING_LARGE
public static final int BUTTONS_SPACING_LARGE- Since:
- 3.4
- See Also:
-
FC_canChooseFiles
public static final int FC_canChooseFiles- Since:
- 3.7
- See Also:
-
FC_canChooseDirectories
public static final int FC_canChooseDirectories- Since:
- 3.7
- See Also:
-
FC_resolvesAliases
public static final int FC_resolvesAliases- Since:
- 3.7
- See Also:
-
FC_allowsMultipleSelection
public static final int FC_allowsMultipleSelection- Since:
- 3.7
- See Also:
-
FC_accessoryViewDisclosed
public static final int FC_accessoryViewDisclosed- Since:
- 3.7
- See Also:
-
FC_showsTagField
public static final int FC_showsTagField- Since:
- 3.7
- See Also:
-
FC_canCreateDirectories
public static final int FC_canCreateDirectories- Since:
- 3.7
- See Also:
-
FC_canSelectHiddenExtension
public static final int FC_canSelectHiddenExtension- Since:
- 3.7
- See Also:
-
FC_showsHiddenFiles
public static final int FC_showsHiddenFiles- Since:
- 3.7
- See Also:
-
FC_extensionHidden
public static final int FC_extensionHidden- Since:
- 3.7
- See Also:
-
FC_allowsOtherFileTypes
public static final int FC_allowsOtherFileTypes- Since:
- 3.7
- See Also:
-
FC_treatsFilePackagesAsDirectories
public static final int FC_treatsFilePackagesAsDirectories- Since:
- 3.7
- See Also:
-
FC_showSingleFilterField
public static final int FC_showSingleFilterField- Since:
- 3.7
- See Also:
-
-
Constructor Details
-
FlatNativeMacLibrary
public FlatNativeMacLibrary()
-
-
Method Details
-
isLoaded
public static boolean isLoaded()Checks whether native library is loaded/available.Note: It is required to invoke this method before invoking any other method of this class. Otherwise, the native library may not be loaded.
-
setWindowRoundedBorder
public static boolean setWindowRoundedBorder(Window window, float radius, float borderWidth, int borderColor) -
setWindowButtonsSpacing
- Since:
- 3.4
-
getWindowButtonsBounds
-
isWindowFullScreen
- Since:
- 3.4
-
toggleWindowFullScreen
- Since:
- 3.4
-
showFileChooser
public static String[] showFileChooser(Window owner, int dark, boolean open, String title, String prompt, String message, String filterFieldLabel, String nameFieldLabel, String nameFieldStringValue, String directoryURL, int optionsSet, int optionsClear, FlatNativeMacLibrary.FileChooserCallback callback, int fileTypeIndex, String[] fileTypes, int[] retFileTypeIndex) Shows the macOS system file dialogs NSOpenPanel or NSSavePanel.Note: This method blocks the current thread until the user closes the file dialog. It is highly recommended to invoke it from a new thread to avoid blocking the AWT event dispatching thread.
- Parameters:
owner- the owner of the file dialog; ornulldark- appearance of the file dialog:1= dark,0= light,-1= defaultopen- iftrue, shows the open dialog; iffalse, shows the save dialogtitle- text displayed at top of save dialog (not used in open dialog); ornullprompt- text displayed in default button; ornullmessage- text displayed at top of open/save dialogs; ornullfilterFieldLabel- text displayed in front of the filter combobox; ornullnameFieldLabel- text displayed in front of the filename text field in save dialog (not used in open dialog); ornullnameFieldStringValue- user-editable filename currently shown in the name field in save dialog (not used in open dialog); ornulldirectoryURL- current directory shown in the dialog; ornulloptionsSet- options to set; seeFC_*constantsoptionsClear- options to clear; seeFC_*constantsfileTypeIndex- the file type that appears as selected (zero-based)fileTypes- file types that the dialog can open or save. Two or more strings andnullare required for each filter. First string is the display name of the filter shown in the combobox (e.g. "Text Files"). Subsequent strings are the file name extensions (e.g. "txt" or "*"; '.' is not supported).nullis required to mark end of filter.retFileTypeIndex- returns selected file type (zero-based); array must be have one element- Returns:
- file path(s) that the user selected; an empty array if canceled;
or
nullon failures (no dialog shown) - Since:
- 3.7.1
-
showMessageDialog
public static int showMessageDialog(long hwndParent, int alertStyle, String messageText, String informativeText, int defaultButton, String... buttons) Shows a macOS alert NSAlert.For use in
FlatNativeMacLibrary.FileChooserCallbackonly.- Parameters:
hwndParent- the parent of the message boxalertStyle- type of alert being displayed:JOptionPane.ERROR_MESSAGE,JOptionPane.INFORMATION_MESSAGEorJOptionPane.WARNING_MESSAGEmessageText- main message of the alertinformativeText- additional information about the alert; shown below of main message; ornulldefaultButton- index of the default button, which can be pressed using ENTER keybuttons- texts of the buttons; if no buttons given the a default "OK" button is shown- Returns:
- index of pressed button
- Since:
- 3.7
-