Interface FileSavePicker

All Superinterfaces:
FilePicker
All Known Implementing Classes:
NativeFileSavePicker, WebFileSavePicker

public interface FileSavePicker extends FilePicker
Interface for a file save picker component that allows users to select a file destination for saving. Extends the FilePicker interface to provide additional functionality for saving files.

This interface provides methods for handling file save operations in a JavaFX application, with implementations that can work in both web browser and native environments.

Use the static create(Node) method to obtain an instance of FileSavePicker, which will return a suitable implementation depending on the runtime environment.

Example usage:


 FileSavePicker fileSavePicker = FileSavePicker.create(node);
 fileSavePicker.setOnFileSelected(file -> {
     return return file -> CompletableFuture.runAsync(() -> {
             // Handle file saving logic here
         });
 });
 
Author:
Besmir Beqiri
See Also:
  • Property Details

  • Method Details

    • create

      static FileSavePicker create(javafx.scene.Node node)
      Creates a new instance of FileSavePicker associated with the specified Node. Depending on whether the application is running in a browser or not, it returns an appropriate implementation.
      Parameters:
      node - the JavaFX node associated with the file save picker
      Returns:
      a new instance of FileSavePicker
    • getOnFileSelected

      Function<File,CompletableFuture<Void>> getOnFileSelected()
      Gets the handler function that is called when the user selects a file to save. The handler accepts a File and returns a CompletableFuture<Void> indicating when the file save operation has completed.
      Returns:
      the handler function for file selection, or null if none is set
    • setOnFileSelected

      void setOnFileSelected(Function<File,CompletableFuture<Void>> value)
      Sets the handler function to be called when the user selects a file to save. The handler function should accept a File object and return a CompletableFuture<Void> that completes when the save operation is finished.
      Parameters:
      value - the handler function to set, or null to remove any existing handler
    • onFileSelectedProperty

      javafx.beans.property.ObjectProperty<Function<File,CompletableFuture<Void>>> onFileSelectedProperty()
      Returns the property representing the handler function that is called when the user selects a file. This property allows for observing changes to the handler and for binding. The handler function accepts a File and returns a CompletableFuture<Void> indicating when the file save operation has completed.
      Returns:
      the property containing the handler function for file selection
      See Also: