Class FlatNativeMacLibrary

java.lang.Object
com.formdev.flatlaf.ui.FlatNativeMacLibrary

public class FlatNativeMacLibrary extends Object
Native methods for macOS.

Note: This is private API. Do not use!

Methods that use windows as parameter

For all methods that accept a Window 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
  • 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

      public static boolean setWindowButtonsSpacing(Window window, int buttonsSpacing)
      Since:
      3.4
    • getWindowButtonsBounds

      public static Rectangle getWindowButtonsBounds(Window window)
      Since:
      3.4
    • isWindowFullScreen

      public static boolean isWindowFullScreen(Window window)
      Since:
      3.4
    • toggleWindowFullScreen

      public static boolean toggleWindowFullScreen(Window window)
      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; or null
      dark - appearance of the file dialog: 1 = dark, 0 = light, -1 = default
      open - if true, shows the open dialog; if false, shows the save dialog
      title - text displayed at top of save dialog (not used in open dialog); or null
      prompt - text displayed in default button; or null
      message - text displayed at top of open/save dialogs; or null
      filterFieldLabel - text displayed in front of the filter combobox; or null
      nameFieldLabel - text displayed in front of the filename text field in save dialog (not used in open dialog); or null
      nameFieldStringValue - user-editable filename currently shown in the name field in save dialog (not used in open dialog); or null
      directoryURL - current directory shown in the dialog; or null
      optionsSet - options to set; see FC_* constants
      optionsClear - options to clear; see FC_* constants
      fileTypeIndex - the file type that appears as selected (zero-based)
      fileTypes - file types that the dialog can open or save. Two or more strings and null are 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). null is 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 null on 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.FileChooserCallback only.

      Parameters:
      hwndParent - the parent of the message box
      alertStyle - type of alert being displayed: JOptionPane.ERROR_MESSAGE, JOptionPane.INFORMATION_MESSAGE or JOptionPane.WARNING_MESSAGE
      messageText - main message of the alert
      informativeText - additional information about the alert; shown below of main message; or null
      defaultButton - index of the default button, which can be pressed using ENTER key
      buttons - texts of the buttons; if no buttons given the a default "OK" button is shown
      Returns:
      index of pressed button
      Since:
      3.7