Is it possible to display files available in the folder when using DirectoryChooser in JavaFX?
directoryChooser.showDialog - This the the dialog for DirectoryChosser in JavaFX.
This question is asked before & i have gone through this JavaFX - display files in the DirectoryChooser
I was able to achieve this using JFileChooser but the UI is completely different JFileChooser select directory but show files
JFileChooser code:
final JFileChooser chooser = new JFileChooser() {
public void approveSelection() {
if (getSelectedFile().isFile()) {
return;
} else{
super.approveSelection();
stubFolder.setText(getCurrentDirectory().getAbsolutePath());
}
}
};
chooser.setFileSelectionMode( JFileChooser.FILES_AND_DIRECTORIES );
if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
System.out.println("getCurrentDirectory(): " + chooser.getCurrentDirectory());
System.out.println("getSelectedFile() : " + chooser.getSelectedFile());
} else {
System.out.println("No Selection ");
}