Class NativeFileDialog


  • public class NativeFileDialog
    extends java.lang.Object
    Bindings to Native File Dialog, a tiny, neat C library that portably invokes native file open and save dialogs. Write dialog code once and have it pop up native dialogs on all supported platforms.

    Usage

    File Filter Syntax

    There is a form of file filtering in every file dialog, but no consistent means of supporting it. NFD provides support for filtering files by groups of extensions, providing its own descriptions (where applicable) for the extensions.

    A wildcard filter is always added to every dialog.

    Separators:

    • ; Begin a new filter.
    • , Add a separate type to the filter.

    Examples:

    • txt The default filter is for text files. There is a wildcard option in a dropdown.
    • png,jpg;psd The default filter is for png and jpg files. A second filter is available for psd files. There is a wildcard option in a dropdown.
    • NULL Wildcard only.

    Known Limitations

    • No support for Windows XP's legacy dialogs such as GetOpenFileName.
    • No support for file filter names -- ex: "Image Files" (*.png, *.jpg). Nameless filters are supported, though.
    • No support for selecting folders instead of files.
    • On Linux, GTK+ cannot be uninitialized to save memory. Launching a file dialog costs memory.
    • Method Detail

      • nNFD_OpenDialog

        public static int nNFD_OpenDialog​(long filterList,
                                          long defaultPath,
                                          long outPath)
        Unsafe version of: OpenDialog
      • NFD_OpenDialog

        public static int NFD_OpenDialog​(@Nullable
                                         java.nio.ByteBuffer filterList,
                                         @Nullable
                                         java.nio.ByteBuffer defaultPath,
                                         PointerBuffer outPath)
        
        public static int NFD_OpenDialog​(@Nullable
                                         java.lang.CharSequence filterList,
                                         @Nullable
                                         java.lang.CharSequence defaultPath,
                                         PointerBuffer outPath)
        
        Launches a single file open dialog.

        If OKAY is returned, outPath will contain a pointer to a UTF-8 encoded string. The user must free the string with Free when it is no longer needed.

        Parameters:
        filterList - an optional filter list
        defaultPath - an optional default path
        outPath - returns the selected file path
      • nNFD_OpenDialogMultiple

        public static int nNFD_OpenDialogMultiple​(long filterList,
                                                  long defaultPath,
                                                  long outPaths)
        Unsafe version of: OpenDialogMultiple
      • NFD_OpenDialogMultiple

        public static int NFD_OpenDialogMultiple​(@Nullable
                                                 java.nio.ByteBuffer filterList,
                                                 @Nullable
                                                 java.nio.ByteBuffer defaultPath,
                                                 NFDPathSet outPaths)
        
        public static int NFD_OpenDialogMultiple​(@Nullable
                                                 java.lang.CharSequence filterList,
                                                 @Nullable
                                                 java.lang.CharSequence defaultPath,
                                                 NFDPathSet outPaths)
        
        Launches a multiple file open dialog.

        If OKAY is returned, outPaths will be filled with information about the selected file or files. The user must free that information with PathSet_Free when it is no longer needed.

        Parameters:
        filterList - an optional filter list
        defaultPath - an optional default path
        outPaths - a path set that will be filled with the selected files
      • nNFD_SaveDialog

        public static int nNFD_SaveDialog​(long filterList,
                                          long defaultPath,
                                          long outPath)
        Unsafe version of: SaveDialog
      • NFD_SaveDialog

        public static int NFD_SaveDialog​(@Nullable
                                         java.nio.ByteBuffer filterList,
                                         @Nullable
                                         java.nio.ByteBuffer defaultPath,
                                         PointerBuffer outPath)
        
        public static int NFD_SaveDialog​(@Nullable
                                         java.lang.CharSequence filterList,
                                         @Nullable
                                         java.lang.CharSequence defaultPath,
                                         PointerBuffer outPath)
        
        Launches a save dialog.

        If OKAY is returned, outPath will contain a pointer to a UTF-8 encoded string. The user must free the string with Free when it is no longer needed.

        Parameters:
        filterList - an optional filter list
        defaultPath - an optional default path
        outPath - returns the selected file path
      • nNFD_PickFolder

        public static int nNFD_PickFolder​(long defaultPath,
                                          long outPath)
        Unsafe version of: PickFolder
      • NFD_PickFolder

        public static int NFD_PickFolder​(@Nullable
                                         java.nio.ByteBuffer defaultPath,
                                         PointerBuffer outPath)
        
        public static int NFD_PickFolder​(@Nullable
                                         java.lang.CharSequence defaultPath,
                                         PointerBuffer outPath)
        
        Launches a select folder dialog.

        If OKAY is returned, outPath will contain a pointer to a UTF-8 encoded string. The user must free the string with Free when it is no longer needed.

        Parameters:
        defaultPath - an optional default path
        outPath - returns the selected file path
      • nNFD_GetError

        public static long nNFD_GetError()
        Unsafe version of: GetError
      • NFD_GetError

        @Nullable
        public static java.lang.String NFD_GetError()
        Returns the last error.
      • nNFD_PathSet_GetCount

        public static long nNFD_PathSet_GetCount​(long pathSet)
        Unsafe version of: PathSet_GetCount
      • NFD_PathSet_GetCount

        public static long NFD_PathSet_GetCount​(NFDPathSet pathSet)
        Returns the number of entries stored in pathSet.
        Parameters:
        pathSet - the path set to query
      • nNFD_PathSet_GetPath

        public static long nNFD_PathSet_GetPath​(long pathSet,
                                                long index)
        Unsafe version of: PathSet_GetPath
      • NFD_PathSet_GetPath

        @Nullable
        public static java.lang.String NFD_PathSet_GetPath​(NFDPathSet pathSet,
                                                           long index)
        Returns the UTF-8 path at offset index.
        Parameters:
        pathSet - the path set to query
        index - the path offset
      • nNFD_PathSet_Free

        public static void nNFD_PathSet_Free​(long pathSet)
        Unsafe version of: PathSet_Free
      • NFD_PathSet_Free

        public static void NFD_PathSet_Free​(NFDPathSet pathSet)
        Frees the contents of the specified path set.
        Parameters:
        pathSet - the path set
      • nNFD_Free

        public static void nNFD_Free​(long outPath)
        Unsafe version of: Free
      • NFD_Free

        public static void NFD_Free​(java.nio.ByteBuffer outPath)
        Frees memory allocated by NativeFileDialog.
        Parameters:
        outPath - the string to free