Class FlatNativeLinuxLibrary

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

public class FlatNativeLinuxLibrary extends Object
Native methods for Linux.

Note: This is private API. Do not use!

Since:
2.5
  • Field Details

    • FC_select_folder

      public static final int FC_select_folder
      https://docs.gtk.org/gtk3/iface.FileChooser.html#properties
      Since:
      3.7
      See Also:
    • FC_select_multiple

      public static final int FC_select_multiple
      https://docs.gtk.org/gtk3/iface.FileChooser.html#properties
      Since:
      3.7
      See Also:
    • FC_show_hidden

      public static final int FC_show_hidden
      https://docs.gtk.org/gtk3/iface.FileChooser.html#properties
      Since:
      3.7
      See Also:
    • FC_local_only

      public static final int FC_local_only
      https://docs.gtk.org/gtk3/iface.FileChooser.html#properties
      Since:
      3.7
      See Also:
    • FC_do_overwrite_confirmation

      public static final int FC_do_overwrite_confirmation
      https://docs.gtk.org/gtk3/iface.FileChooser.html#properties
      Since:
      3.7
      See Also:
    • FC_create_folders

      public static final int FC_create_folders
      https://docs.gtk.org/gtk3/iface.FileChooser.html#properties
      Since:
      3.7
      See Also:
  • Constructor Details

    • FlatNativeLinuxLibrary

      public FlatNativeLinuxLibrary()
  • 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.

    • isGtk3Available

      public static boolean isGtk3Available()
      Checks whether GTK 3 is available. Use this before invoking any native method that uses GTK. Otherwise the app may terminate immediately if GTK is not installed.

      This works because Java uses dlopen(RTLD_LAZY) to load JNI libraries, which only resolves symbols as the code that references them is executed.

      Since:
      3.7
    • showFileChooser

      public static String[] showFileChooser(Window owner, int dark, boolean open, String title, String okButtonLabel, String currentName, String currentFolder, int optionsSet, int optionsClear, FlatNativeLinuxLibrary.FileChooserCallback callback, int fileTypeIndex, String[] fileTypes, int[] retFileTypeIndex)
      Shows the Linux/GTK system file dialog GtkFileChooserDialog.

      Uses GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER if FC_select_folder is set in parameter optionsSet. Otherwise uses GTK_FILE_CHOOSER_ACTION_OPEN if parameter open is true, or GTK_FILE_CHOOSER_ACTION_SAVE if false.

      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 - preferred appearance of the file dialog: 1 = prefer dark, 0 = prefer light, -1 = default
      open - if true, shows the open dialog; if false, shows the save dialog
      title - text displayed in dialog title; or null
      okButtonLabel - text displayed in default button; or null. Use '_' for mnemonics (e.g. "_Choose") Use '__' for '_' character (e.g. "Choose__and__Quit").
      currentName - user-editable filename currently shown in the filename field in save dialog; or null
      currentFolder - current directory shown in the dialog; or null
      optionsSet - options to set; see FC_* constants
      optionsClear - options to clear; see FC_* constants
      callback - approve callback; or null
      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 filter patterns (e.g. "*.txt" or "*"). 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 messageType, String primaryText, String secondaryText, int defaultButton, String... buttons)
      Shows a GTK message box GtkMessageDialog.

      For use in FlatNativeLinuxLibrary.FileChooserCallback only.

      Parameters:
      hwndParent - the parent of the message box
      messageType - type of message being displayed: JOptionPane.ERROR_MESSAGE, JOptionPane.INFORMATION_MESSAGE, JOptionPane.WARNING_MESSAGE, JOptionPane.QUESTION_MESSAGE or JOptionPane.PLAIN_MESSAGE
      primaryText - primary text; if the dialog has a secondary text, this will appear as title in a larger bold font
      secondaryText - secondary text; shown below of primary text; 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. Use '_' for mnemonics (e.g. "_Choose") Use '__' for '_' character (e.g. "Choose__and__Quit").
      Returns:
      index of pressed button; or -1 for ESC key
      Since:
      3.7