prompt For Directory using JavaFX DirectoryChooser - Java JavaFX

Java examples for JavaFX:DirectoryChooser

Description

prompt For Directory using JavaFX DirectoryChooser

Demo Code


import java.io.File;
import java.util.Optional;
import javafx.scene.Node;
import javafx.scene.control.TextInputDialog;
import javafx.stage.DirectoryChooser;
import javafx.stage.Stage;

public class Main{
    public static File promptForDirectory() {
        return promptForDirectory(stage);
    }/* w  w  w  .  j a  v  a 2 s  . c o m*/
    public static File promptForDirectory(Stage stage) {
        DirectoryChooser directoryChooser = new DirectoryChooser();
        directoryChooser.setTitle("Choose Folder");
        directoryChooser.setInitialDirectory(new File("."));

        return directoryChooser.showDialog(stage);
    }
}

Related Tutorials