javafilejavafxfilechooser

Javafx filechooser name filter


i'd like to know if there's a way of filtering the names of files to make them selectable in the dialog to select files, for instance all files that starts for "A" and are in txt format, i searched a bit and i found only tips topics about the extension with the Extension filter, that's fine but i'd like to select just some file in a format.


Solution

  • Of course , you can get some idea from this example; in Java Swing( I'm not sure how in JavaFX) you can filter files by name or extension like :

    FileChooser fileChooser = new FileChooser();
    FileFilter filter = new FileNameExtensionFilter("MP3 File","mp3");
    fileChooser.setFileFilter(filter)`