List of usage examples for javax.swing JFileChooser DIRECTORIES_ONLY
int DIRECTORIES_ONLY
To view the source code for javax.swing JFileChooser DIRECTORIES_ONLY.
Click Source Link
From source file:nz.govt.natlib.ndha.manualdeposit.metadata.MetaDataConfiguratorPresenter.java
private boolean chooseDirectory(String initialDirectory, String title) { chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); boolean result = chooseFile(initialDirectory, title, true); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); return result; }
From source file:op.controlling.PnlControlling.java
private JPanel createContentPanel4Hygiene() { JPanel pnlContent = new JPanel(new VerticalLayout()); JPanel pnlPrevalence = new JPanel(new BorderLayout()); final JButton btnPrevalence = GUITools.createHyperlinkButton("opde.controlling.hygiene.prevalence", null, null);// w w w . j a v a 2 s . co m final JDateChooser jdc = new JDateChooser(new Date()); final JCheckBox cbAnonymous = new JCheckBox(SYSTools.xx("misc.msg.anon")); cbAnonymous.setSelected(true); jdc.setMaxSelectableDate(new Date()); btnPrevalence.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { OPDE.getMainframe().setBlocked(true); SwingWorker worker = new SwingWorker() { @Override protected Object doInBackground() throws Exception { MREPrevalenceSheets mre = new MREPrevalenceSheets(new LocalDate(), cbAnonymous.isSelected(), progressClosure); return mre.createSheet(); } @Override protected void done() { try { File source = (File) get(); Object[] options = { SYSTools.xx("prevalence.optiondialog.option1"), SYSTools.xx("prevalence.optiondialog.option2"), SYSTools.xx("opde.wizards.buttontext.cancel") }; int n = JOptionPane.showOptionDialog(OPDE.getMainframe(), SYSTools.xx("prevalence.optiondialog.question"), SYSTools.xx("prevalence.optiondialog.title"), JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]); File copyTargetDirectory = null; if (n == 1) { JFileChooser chooser = new JFileChooser(); chooser.setDialogTitle("title"); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setMultiSelectionEnabled(false); chooser.setAcceptAllFileFilterUsed(false); if (chooser.showOpenDialog(pnlPrevalence) == JFileChooser.APPROVE_OPTION) { copyTargetDirectory = chooser.getSelectedFile(); } } if (copyTargetDirectory != null) { FileUtils.copyFile(source, copyTargetDirectory); } else { if (n == 0) { SYSFilesTools.handleFile((File) get(), Desktop.Action.OPEN); } } } catch (Exception e) { OPDE.fatal(e); } OPDE.getDisplayManager().setProgressBarMessage(null); OPDE.getMainframe().setBlocked(false); } }; worker.execute(); } }); pnlPrevalence.add(btnPrevalence, BorderLayout.WEST); JPanel optionPanel = new JPanel(); optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.LINE_AXIS)); optionPanel.add(cbAnonymous); optionPanel.add(jdc); pnlPrevalence.add(optionPanel, BorderLayout.EAST); pnlContent.add(pnlPrevalence); return pnlContent; }
From source file:org.andrewberman.sync.PDFDownloader.java
static File chooseDirectory() throws Exception { JFileChooser fc = new JFileChooser(); // fc.setDialogTitle("Choose Output Directory"); // Start in current directory fc.setCurrentDirectory(new File(".")); // Choose only directories only. fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // Open chooser dialog int result = fc.showSaveDialog(new JFrame()); if (result == JFileChooser.CANCEL_OPTION) { out.println("Directory choice was canceled. Exiting..."); // System.exit(1); throw new Exception(); }//from w w w . ja v a 2 s . c o m File f = fc.getSelectedFile(); out.println("Chosen directory:" + f); return f; }
From source file:org.apache.cayenne.modeler.dialog.codegen.GeneratorController.java
/** * An action method that pops up a file chooser dialog to pick the * generation directory.//from w ww.j a v a 2 s. com */ public void selectOutputFolderAction() { JTextField outputFolder = ((GeneratorControllerPanel) getView()).getOutputFolder(); String currentDir = outputFolder.getText(); JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setDialogType(JFileChooser.OPEN_DIALOG); // guess start directory if (!Util.isEmptyString(currentDir)) { chooser.setCurrentDirectory(new File(currentDir)); } else { FSPath lastDir = Application.getInstance().getFrameController().getLastDirectory(); lastDir.updateChooser(chooser); } int result = chooser.showOpenDialog(getView()); if (result == JFileChooser.APPROVE_OPTION) { File selected = chooser.getSelectedFile(); // update model String path = selected.getAbsolutePath(); outputFolder.setText(path); setOutputPath(path); } }
From source file:org.apache.cayenne.modeler.dialog.pref.ClasspathPreferences.java
protected void addClassDirectoryAction() { chooseClassEntry(null, "Select Java Class Directory.", JFileChooser.DIRECTORIES_ONLY); }
From source file:org.apache.oodt.cas.workflow.gui.WorkflowGUI.java
public JMenuBar generateMenuBar() { JMenuBar bar = new JMenuBar(); FileMenu fileMenu = new FileMenu(); bar.add(fileMenu);/*from w w w . ja v a 2 s .co m*/ fileMenu.getExit().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent event) { System.exit(1); } }); fileMenu.getOpenWorkspace().addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { JFileChooser chooser = new JFileChooser(new File(".")) { boolean acceptFile(File f) { return f.isDirectory(); } }; chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int value = chooser.showOpenDialog(WorkflowGUI.this); if (value == JFileChooser.APPROVE_OPTION) { workspace = chooser.getSelectedFile(); updateWorkspaceText(); perspective.reset(); loadProjects(); } } catch (Exception e1) { e1.printStackTrace(); } } }); fileMenu.getImport().addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { if (workspace == null) { return; } JFileChooser chooser = new JFileChooser(new File(".")); int value = chooser.showOpenDialog(WorkflowGUI.this); if (value == JFileChooser.APPROVE_OPTION) { File file = chooser.getSelectedFile(); XmlWorkflowModelRepositoryFactory factory = new XmlWorkflowModelRepositoryFactory(); factory.setWorkspace(workspace.getAbsolutePath()); View activeView = perspective.getActiveView(); if (activeView != null) { // TODO: add code for import } } } catch (Exception e) { LOG.log(Level.SEVERE, e.getMessage()); } } }); fileMenu.getNewWorkspace().addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { JFileChooser chooser = new JFileChooser(new File(".")) { boolean acceptFile(File f) { return f.isDirectory(); } }; chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int value = chooser.showOpenDialog(WorkflowGUI.this); if (value == JFileChooser.APPROVE_OPTION) { workspace = chooser.getSelectedFile(); updateWorkspaceText(); perspective.reset(); loadProjects(); perspective.refresh(); } } }); fileMenu.getNewProject().addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { // TODO: add new project code } }); fileMenu.getSave().addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { repo.save(); } catch (Exception e) { LOG.log(Level.SEVERE, e.getMessage()); } } }); EditMenu editMenu = new EditMenu(); bar.add(editMenu); editMenu.getUndo().addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { try { perspective.undo(); } catch (Exception e) { LOG.log(Level.SEVERE, e.getMessage()); } } }); bar.revalidate(); return bar; }
From source file:org.clipsmonitor.gui.MapGeneratorTopComponent.java
public MapGeneratorTopComponent() { initComponents();/* w w w. j ava2 s . com*/ setName(Bundle.CTL_MapGeneratorTopComponent()); setToolTipText(Bundle.HINT_MapGeneratorTopComponent()); model = RescueGenMap.getInstance(); img = MonitorImages.getInstance(); int x = Integer.parseInt(XButton.getText()); int y = Integer.parseInt(YButton.getText()); actualPosClicked = new int[2]; actualPosClicked[0] = (x / 2) + 1; actualPosClicked[1] = (y / 2) + 1; actualPath = "empty"; WaitTime.setText("0"); LogArea.setText(model.getLog()); initComboBox(); MakePersonList(); MakeStepList(-1); MakeMoveList(-1, -1, "all"); MakePathList(-1); state = InsertionOptionComboBox.getSelectedItem().toString(); model.initModelMap(x, y, PreviewMap.getWidth(), PreviewMap.getHeight()); directory = ProjectDirectory.getIstance(new File("./")); fc = new JFileChooser(); save = new JFileChooser(); json = new JFileChooser(); fc.setCurrentDirectory(directory.getProjectDirectory()); fc.setFileFilter(new JSONFilter()); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); save.setCurrentDirectory(directory.getProjectDirectory()); save.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); json.setCurrentDirectory(directory.getProjectDirectory()); json.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); setButtons(true); setListEnable(); updateLogArea(); }
From source file:org.domainmath.gui.MainFrame.java
public void browse() { JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new File(System.getProperty("user.dir") + File.separator + "works")); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fc.setMultiSelectionEnabled(false);/*from ww w . ja v a 2 s. com*/ File _file; int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { _file = fc.getSelectedFile(); setDir(_file.getAbsolutePath()); } }
From source file:org.domainmath.gui.MainFrame.java
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed JFileChooser fc = new JFileChooser(); fc.setCurrentDirectory(new File(System.getProperty("user.dir") + File.separator + "works")); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fc.setMultiSelectionEnabled(false);//from w w w . j a v a 2 s .c o m Path browse_file; int returnVal = fc.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { browse_file = fc.getSelectedFile().toPath(); setDir(browse_file.toString()); requestToChangeDir(browse_file.toString()); fileTreePanel.updateFileTree(fc.getSelectedFile()); } }
From source file:org.drugis.mtc.gui.GeneratedCodeWindow.java
private JButton createSaveButton() { JButton saveButton = new JButton("Save", MainWindow.IMAGELOADER.getIcon("savefile.gif")); saveButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); int returnVal = chooser.showSaveDialog(GeneratedCodeWindow.this); if (returnVal == JFileChooser.APPROVE_OPTION) { File file = chooser.getSelectedFile(); if (!file.isDirectory()) { JOptionPane.showMessageDialog(GeneratedCodeWindow.this, "Error: please select a directory to save to", "Files could not be saved.", JOptionPane.ERROR_MESSAGE); }/* w w w . j a va 2s. com*/ writeFiles(file); JOptionPane.showMessageDialog(GeneratedCodeWindow.this, "Your files have been saved to: \n" + file.getPath(), "Files saved.", JOptionPane.INFORMATION_MESSAGE); } } catch (IOException e) { JOptionPane.showMessageDialog(GeneratedCodeWindow.this, "Error: " + e.getMessage(), "Files could not be saved.", JOptionPane.ERROR_MESSAGE); } } }); return saveButton; }