/** * Show an open dialog that allows multiple selection. * @return An array of files, or null if the user cancelled the dialog */ public File[] showMultiOpenDialog() { JFileChooser chooser = createFileChooser(); chooser.setMultiSelectionEnabled(true); int result = chooser.showOpenDialog(findDialogParent()); if (JFileChooser.APPROVE_OPTION == result) { File[] files = chooser.getSelectedFiles(); return files == null ? new File[0] : files; } else { return null; } }
/** * Show an open dialog with a file chooser set up according to the * parameters of this builder. * @return A file if the user clicks the accept button and a file or * folder was selected at the time the user clicked cancel. */ public File showOpenDialog() { JFileChooser chooser = createFileChooser(); if( Boolean.getBoolean("nb.native.filechooser") ) { //NOI18N FileDialog fileDialog = createFileDialog( chooser.getCurrentDirectory() ); if( null != fileDialog ) { return showFileDialog(fileDialog, FileDialog.LOAD ); } } chooser.setMultiSelectionEnabled(false); int dlgResult = chooser.showOpenDialog(findDialogParent()); if (JFileChooser.APPROVE_OPTION == dlgResult) { File result = chooser.getSelectedFile(); if (result != null && !result.exists()) { result = null; } return result; } else { return null; } }
/** * Show a save dialog with the file chooser set up according to the * parameters of this builder. * @return A file if the user clicks the accept button and a file or * folder was selected at the time the user clicked cancel. */ public File showSaveDialog() { JFileChooser chooser = createFileChooser(); if( Boolean.getBoolean("nb.native.filechooser") ) { //NOI18N FileDialog fileDialog = createFileDialog( chooser.getCurrentDirectory() ); if( null != fileDialog ) { return showFileDialog( fileDialog, FileDialog.SAVE ); } } int result = chooser.showSaveDialog(findDialogParent()); if (JFileChooser.APPROVE_OPTION == result) { return chooser.getSelectedFile(); } else { return null; } }
fileChooserBuilder.setDirectoriesOnly(true); JFileChooser jfc = fileChooserBuilder.createFileChooser(); int value = jfc.showOpenDialog(WindowManager.getDefault().getMainWindow());
final JFileChooser chooser = builder.createFileChooser(); chooser.setMultiSelectionEnabled(true); chooser.addActionListener(new ActionListener() {
final JFileChooser chooser = builder.createFileChooser(); chooser.setMultiSelectionEnabled(true); chooser.addActionListener(new ActionListener() {