FileChooser/DirectoryChooser for exporting data

Hi, I am trying to find a similar dialog to a directory chooser.
I am trying to export a file with data in it, but I want the user to choose a directory where the file would be exported (downloaded).
In Java I have this code:

public void onExportBtnClick(Component component) throws IOException, FileStorageException {
    JFileChooser chooser = new JFileChooser();
    chooser.setCurrentDirectory(new File("."));
    chooser.setDialogTitle("Choose folder");
    if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
       File x = new File(chooser.getCurrentDirectory() +"/export-data.csv");

But the dialog won’t appear in the view, instead the app stops responding.

Is there some predefined Dialog I could use for this purpose?



Take a look at the ExportDisplay interface. You can read more in the documentation.

1 Like