File selection/save dialog with filter

After a lot of research, I came up with a better file select (and you can easily figure out a save dialog from this) dialog -

import static javafx.stage.FileChooser.ExtensionFilter;
import javafx.stage.FileChooser;

protected File selectFilteredInput(String title, ExtensionFilter... filters) {

  //my code
  FileChooser fileChooser = new FileChooser();
  File selectedFile = fileChooser.showOpenDialog(null);
  return selectedFile;

Follow what I say here to install the JavaFX library.


  • edited April 2017

    And a clear advantage of this is that it works on Windows as well, unlike FileDialog.
    Problem is - it only works with FX2D renderer.

Sign In or Register to comment.