List of usage examples for javax.swing JFileChooser setMultiSelectionEnabled
@BeanProperty(description = "Sets multiple file selection mode.") public void setMultiSelectionEnabled(boolean b)
From source file:org.pgptool.gui.ui.tools.browsefs.MultipleFilesChooserDialog.java
private JFileChooser buildFileChooserDialog() { JFileChooser ofd = new JFileChooser(); ofd.setFileSelectionMode(JFileChooser.FILES_ONLY); ofd.setAcceptAllFileFilterUsed(true); ofd.setMultiSelectionEnabled(true); ofd.setDialogTitle(Messages.get("action.chooseExistingFile")); ofd.setApproveButtonText(Messages.get("action.choose")); suggestInitialDirectory(ofd);/*from w w w . jav a 2s . co m*/ doFileChooserPostConstruct(ofd); return ofd; }
From source file:cool.pandora.modeller.ui.handlers.base.AddDataHandler.java
/** * addData./*w w w. ja va 2 s.com*/ */ void addData() { final File selectFile = new File(File.separator + "."); final JFrame frame = new JFrame(); final JFileChooser fc = new JFileChooser(selectFile); fc.setDialogType(JFileChooser.OPEN_DIALOG); fc.setMultiSelectionEnabled(true); fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); fc.setDialogTitle("Add File or Directory"); final int option = fc.showOpenDialog(frame); if (option == JFileChooser.APPROVE_OPTION) { final File[] files = fc.getSelectedFiles(); final String message = ApplicationContextUtil.getMessage("bag.message.filesadded"); if (files != null && files.length > 0) { addBagData(files); ApplicationContextUtil.addConsoleMessage(message + " " + getFileNames(files)); } else { final File file = fc.getSelectedFile(); addBagData(file); ApplicationContextUtil.addConsoleMessage(message + " " + file.getAbsolutePath()); } bagView.bagPayloadTreePanel.refresh(bagView.bagPayloadTree); bagView.updateAddData(); } }
From source file:filesscanner.MainWindow.java
private JFileChooser ShowChooser(File f) { JFileChooser chooser = new JFileChooser(f); chooser.setMultiSelectionEnabled(true); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); return chooser; }
From source file:org.pmedv.jake.commands.AddFilesCommand.java
@Override public void execute() { final ApplicationContext ctx = AppContext.getApplicationContext(); final ApplicationWindow win = (ApplicationWindow) ctx.getBean(BeanDirectory.WINDOW_APPLICATION); /**// ww w . j ava 2s. c o m * Get last selected folder to simplify file browsing */ if (AppContext.getLastSelectedFolder() == null) AppContext.setLastSelectedFolder(System.getProperty("user.home")); JFileChooser fc = new JFileChooser(AppContext.getLastSelectedFolder()); fc.setDialogTitle("Add files"); fc.setMultiSelectionEnabled(true); fc.setFileFilter(new MP3Filter()); int result = fc.showOpenDialog(win); if (result == JFileChooser.CANCEL_OPTION) return; File[] files = fc.getSelectedFiles(); PlayerView view = JakeUtil.getCurrentActivePlayer(); if (view == null) { ArrayList<File> fileList = new ArrayList<File>(); for (int i = 0; i < files.length; i++) fileList.add(files[i]); final PlayerController controller = new PlayerController(fileList); JakeUtil.updateRecentFiles(fc.getSelectedFile().getAbsolutePath()); AppContext.setLastSelectedFolder(fc.getSelectedFiles()[0].getParentFile().getAbsolutePath()); View v = new View(fc.getSelectedFile().getAbsolutePath(), null, controller.getPlayerView()); v.addListener(new DockingWindowAdapter() { @Override public void windowClosing(DockingWindow arg0) throws OperationAbortedException { controller.getPlayer().close(); controller.getPlayFileCommand().setPlaying(false); } }); openEditor(v); } else { if (files.length >= 1) { AppContext.setLastSelectedFolder(fc.getSelectedFiles()[0].getParentFile().getAbsolutePath()); JakeUtil.updateRecentFiles(fc.getSelectedFiles()[0].getParentFile().getAbsolutePath()); FileTableModel model = (FileTableModel) view.getFileTable().getModel(); for (int i = 0; i < files.length; i++) { model.addObject(files[i]); } } } }
From source file:it.unibo.alchemist.boundary.gui.Perspective.java
private void openFile() { final JFileChooser fc = new JFileChooser(); fc.setMultiSelectionEnabled(false); fc.setFileFilter(FILE_FILTER);//from w ww. j av a 2 s. co m fc.setCurrentDirectory(currentDirectory); final int returnVal = fc.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { fileToLoad = fc.getSelectedFile(); currentDirectory = fc.getSelectedFile().getParentFile(); if (fileToLoad.exists()) { status.setText(getString("ready_to_process") + " " + fileToLoad.getAbsolutePath()); status.setOK(); if (sim != null) { sim.addCommand(new Engine.StateCommand<T>().stop().build()); } bar.setFileOK(true); } else { status.setText(FILE_NOT_VALID + " " + fileToLoad.getAbsolutePath()); status.setNo(); bar.setFileOK(false); } } }
From source file:edu.umich.robot.GuiApplication.java
/** * <p>/*from www .j a v a2 s. co m*/ * Firing up this application requires a configuration file. If no * configuration file is presented on the command line, this is called to * prompt the user to select a configuration file. * * <p> * Future work should probably include some default instead of doing this. * * @return The selected, loaded configuration file. */ public static Config promptForConfig(Component parent) { System.out.println("CLASSPATH: " + System.getenv("CLASSPATH")); System.out.println("DYLD_LIBRARY_PATH: " + System.getenv("DYLD_LIBRARY_PATH")); System.out.println("LD_LIBRARY_PATH: " + System.getenv("LD_LIBRARY_PATH")); System.out.println("SOAR_HOME: " + System.getenv("SOAR_HOME")); System.out.println("java.library.path: " + System.getProperty("java.library.path")); JFileChooser fc = new JFileChooser(System.getProperty("user.dir")); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); FileFilter filter = new FileNameExtensionFilter("Text Config File", "txt"); fc.setFileFilter(filter); fc.setMultiSelectionEnabled(false); int ret = fc.showOpenDialog(parent); if (ret == JFileChooser.APPROVE_OPTION) { try { return new ConfigFile(fc.getSelectedFile().getAbsolutePath()); } catch (IOException e) { logger.error(e.getMessage()); } } return null; }
From source file:net.aepik.alasca.gui.util.LoadFileFrame.java
/** * Perform action on event for this object. *//* w ww. j a va 2 s.c om*/ public void actionPerformed(ActionEvent e) { Object o = e.getSource(); if (o == boutonOpenFile) { JFileChooser jfcProgramme = new JFileChooser("."); jfcProgramme.setMultiSelectionEnabled(false); jfcProgramme.setDialogTitle("Selectionner un fichier"); jfcProgramme.setApproveButtonText("Selectionner"); jfcProgramme.setApproveButtonToolTipText("Cliquer apres avoir selectionn un fichier"); jfcProgramme.setAcceptAllFileFilterUsed(false); if (jfcProgramme.showDialog(this, null) == JFileChooser.APPROVE_OPTION) { try { filename.setText(jfcProgramme.getSelectedFile().getCanonicalPath()); } catch (IOException ioe) { JOptionPane.showMessageDialog(null, "Erreur de nom de fichier.", "Erreur", JOptionPane.ERROR_MESSAGE); } } } if (o == boutonOk && filename.getText().length() != 0) { if (!this.loadFile(filename.getText(), (String) this.syntaxes.getSelectedItem())) { JOptionPane.showMessageDialog(this, this.getErrorMessage(), "Erreur", JOptionPane.ERROR_MESSAGE); } else { windowClosing(null); } } if (o == boutonAnnuler) { windowClosing(null); } }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopFileMultiUploadField.java
public DesktopFileMultiUploadField() { fileUploading = AppBeans.get(FileUploadingAPI.NAME); final JFileChooser fileChooser = new JFileChooser(); fileChooser.setMultiSelectionEnabled(true); DesktopResources resources = App.getInstance().getResources(); Messages messages = AppBeans.get(Messages.NAME); String caption = messages.getMessage(getClass(), "upload.selectFiles"); impl = new JButton(); impl.setAction(new AbstractAction(caption, resources.getIcon(DEFAULT_ICON)) { @Override/*w w w.j ava 2 s.c o m*/ public void actionPerformed(ActionEvent e) { if (fileChooser.showOpenDialog(impl) == JFileChooser.APPROVE_OPTION) { processFiles(fileChooser.getSelectedFiles()); } } }); DesktopComponentsHelper.adjustSize(impl); }
From source file:edu.umich.robot.ViewerApplication.java
private Config promptForConfig() { JFileChooser fc = new JFileChooser("config"); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); FileFilter filter = new FileNameExtensionFilter("Text Config File", "txt"); fc.setFileFilter(filter);/*from w ww .j av a 2s.co m*/ fc.setMultiSelectionEnabled(false); int ret = fc.showOpenDialog(frame); if (ret == JFileChooser.APPROVE_OPTION) { try { return new ConfigFile(fc.getSelectedFile().getAbsolutePath()); } catch (IOException e) { logger.error(e.getMessage()); } } return null; }
From source file:com.egangotri.transliteratorAsSwing.TransliteratorJFrame.java
public void chooseFile(JTextArea jta) { JFileChooser chooser = new JFileChooser(); chooser.setMultiSelectionEnabled(false); FileNameExtensionFilter filter = new FileNameExtensionFilter("TEXT FILES", "txt", "text"); chooser.setFileFilter(filter);//from ww w .j a v a 2 s .co m int option = chooser.showOpenDialog(this); if (option == JFileChooser.APPROVE_OPTION) { if (chooser.getSelectedFile() != null) { Log.info("You chose to open this file: " + chooser.getSelectedFile().getPath()); String path = chooser.getSelectedFile().getPath(); FileIO.readFile(new File(path), jta); } } }