Klasse FileChooserBuilder

java.lang.Object
com.dua3.utility.fx.controls.FileChooserBuilder

public class FileChooserBuilder extends Object
Builder for file open/save dialogs.

Provides a fluent interface to create file dialogs.

  • Methodendetails

    • showOpenDialog

      public Optional<Path> showOpenDialog(@Nullable Window parent)
      Show "Open" dialog.
      Parameter:
      parent - the parent window
      Gibt zurück:
      an Optional containing the selected file.
    • showOpenMultipleDialog

      public List<Path> showOpenMultipleDialog(@Nullable Window parent)
      Show "Open multiple" dialog.
      Parameter:
      parent - the parent window
      Gibt zurück:
      a List containing the selected files, or an empty list if no files were selected
    • showSaveDialog

      public Optional<Path> showSaveDialog(@Nullable Window parent)
      Show "Save" dialog.
      Parameter:
      parent - the parent window
      Gibt zurück:
      an Optional containing the selected file.
    • initialFile

      public FileChooserBuilder initialFile(Path file)
      Set initial filename and directory.
      Parameter:
      file - the file
      Gibt zurück:
      this instance
    • initialFileName

      public FileChooserBuilder initialFileName(@Nullable String initialFileName)
      Set initial filename.
      Parameter:
      initialFileName - the initial filename
      Gibt zurück:
      this instance
    • initialDir

      public FileChooserBuilder initialDir(@Nullable Path initialDir)
      Set initial directory. If the initial directory is inaccessible or non-existent, it will be ignored when creating the dialog. If it exists, but is a regular file, the dialog will be created with the file's parent directory set as its initial directory.
      Parameter:
      initialDir - the initial directory
      Gibt zurück:
      this instance
    • addFilter

      public FileChooserBuilder addFilter(String name, String... pattern)
      Add filter to the list of filters.
      Parameter:
      name - the filter name
      pattern - the pattern(s) to use for this filter
      Gibt zurück:
      this instance
    • filter

      Set filters.

      The current filters will be replaced.

      Parameter:
      filters - the filters to set
      Gibt zurück:
      this instance
    • filter

      public FileChooserBuilder filter(FileChooser.ExtensionFilter... filters)
      Set filters.

      The current filters will be replaced.

      Parameter:
      filters - the filters to set
      Gibt zurück:
      this instance
    • selectedFilter

      public FileChooserBuilder selectedFilter(@Nullable FileChooser.ExtensionFilter f)
      Set selected filter.

      The filter is appended to the list of filters if not present.

      Parameter:
      f - the selected filter
      Gibt zurück:
      this instance