@Override public void actionPerformed(ActionEvent e) { FolderChooser folderChooser = new FolderChooser(); folderChooser.setCurrentDirectory(new File(getDefaultOutputPath(appContext))); folderChooser.setDialogTitle("Select output directory"); folderChooser.setMultiSelectionEnabled(false); int result = folderChooser.showDialog(appContext.getApplicationWindow(), "Select"); /*I18N*/ if (result != JFileChooser.APPROVE_OPTION) { return; } File selectedFile = folderChooser.getSelectedFile(); setOutputDirPath(selectedFile.getAbsolutePath()); try { outputFileProperty.setValue(selectedFile); appContext.getPreferences().setPropertyString(LAST_OPEN_OUTPUT_DIR, selectedFile.getAbsolutePath()); } catch (ValidationException ve) { // not expected to ever come here appContext.handleError("Invalid input path", ve); } } });
private AbstractButton createOutputDirChooserButton(final Property outputFileProperty) { AbstractButton button = new JButton("..."); button.addActionListener(e -> { FolderChooser folderChooser = new FolderChooser(); folderChooser.setCurrentDirectory(new File(getDefaultOutputPath(appContext))); folderChooser.setDialogTitle("Select output directory"); folderChooser.setMultiSelectionEnabled(false); int result = folderChooser.showDialog(appContext.getApplicationWindow(), "Select"); /*I18N*/ if (result != JFileChooser.APPROVE_OPTION) { return; } File selectedFile = folderChooser.getSelectedFile(); setOutputDirPath(selectedFile.getAbsolutePath()); try { outputFileProperty.setValue(selectedFile); appContext.getPreferences().setPropertyString(PROPERTY_NAME_LAST_OPEN_OUTPUT_DIR, selectedFile.getAbsolutePath()); } catch (ValidationException ve) { // not expected to ever come here appContext.handleError("Invalid input path", ve); } }); return button; }
folderChooser.setCurrentDirectory(new File(lastDir)); folderChooser.setMultiSelectionEnabled(!recursive);
folderChooser.setCurrentDirectory(new File(lastDir)); folderChooser.setMultiSelectionEnabled(!recursive);