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:view.ViewFiltrar.java
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed JFileChooser chooserDiretorio = new JFileChooser(ViewPrincipal.ROOTWOKSPACE); chooserDiretorio.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooserDiretorio.setDialogTitle("Escolha o diretrio de saida."); resultado = chooserDiretorio.showOpenDialog(getParent()); if (resultado == JFileChooser.APPROVE_OPTION) { String path = chooserDiretorio.getSelectedFile().getPath(); jTextFieldOutputDiretorioFiltragem.setText(path); } else if (resultado == JFileChooser.CANCEL_OPTION) System.out.println("Cancelado."); }
From source file:view.WorkspacePanel.java
public void signBatch(CCSignatureSettings settings) { ArrayList<File> toSignList = mainWindow.getOpenedFiles(); try {/*from w w w . j a va 2 s. c o m*/ if (tempCCAlias.getMainCertificate().getPublicKey().equals( CCInstance.getInstance().loadKeyStoreAndAliases().get(0).getMainCertificate().getPublicKey())) { String dest = null; Object[] options = { Bundle.getBundle().getString("opt.saveInOriginalFolder"), Bundle.getBundle().getString("msg.choosePath"), Bundle.getBundle().getString("btn.cancel") }; int i = JOptionPane.showOptionDialog(null, Bundle.getBundle().getString("msg.chooseSignedPath"), "", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (i == 1) { JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File(".")); chooser.setDialogTitle(Bundle.getBundle().getString("btn.choosePath")); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setAcceptAllFileFilterUsed(false); if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { dest = chooser.getSelectedFile().getAbsolutePath(); } else { return; } } else if (i == 2) { return; } MultipleSignDialog msd = new MultipleSignDialog(mainWindow, true, toSignList, settings, dest); msd.setLocationRelativeTo(null); msd.setVisible(true); ArrayList<File> signedDocsList = msd.getSignedDocsList(); if (!signedDocsList.isEmpty()) { removeTempSignature(); clearSignatureFields(); hideRightPanel(); status = Status.READY; mainWindow.closeDocuments(mainWindow.getOpenedFiles(), false); for (File f : signedDocsList) { mainWindow.loadPdf(f, false); } } return; } else { JOptionPane.showMessageDialog(mainWindow, Bundle.getBundle().getString("msg.smartcardRemovedOrChanged"), WordUtils.capitalize(Bundle.getBundle().getString("error")), JOptionPane.ERROR_MESSAGE); } } catch (LibraryNotLoadedException | KeyStoreNotLoadedException | CertificateException | KeyStoreException | LibraryNotFoundException | AliasException ex) { controller.Logger.getLogger().addEntry(ex); } JOptionPane.showMessageDialog(mainWindow, Bundle.getBundle().getString("msg.smartcardRemovedOrChanged"), WordUtils.capitalize(Bundle.getBundle().getString("error")), JOptionPane.ERROR_MESSAGE); }
From source file:wqm.util.ProcessDataGUI.java
public static void main(String[] args) throws IOException, ParseException { JFileChooser fc = new JFileChooser(); fc.setDialogTitle("Select data file."); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); fc.setMultiSelectionEnabled(true);// w w w . ja va2s. c o m int returnVal = fc.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { File[] files = fc.getSelectedFiles(); fc.setDialogTitle("Select output location."); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fc.setMultiSelectionEnabled(false); returnVal = fc.showOpenDialog(null); if (returnVal == JFileChooser.APPROVE_OPTION) { File outputDirectory = fc.getSelectedFile(); for (File inputFile : files) { ProcessData .main(new String[] { inputFile.getAbsolutePath(), outputDirectory.getAbsolutePath() }); } } } }
From source file:zsk.JFCMainClient.java
/** * process events of ActionListener/*from w w w .j ava2 s . c o m*/ * */ public void actionPerformed(final ActionEvent e) { if (e.getSource().equals(frame.textinputfield)) { if (!e.getActionCommand().equals("")) { if (e.getActionCommand().matches(szYTREGEX)) addYTURLToList(e.getActionCommand()); else { addTextToConsole(e.getActionCommand()); cli(e.getActionCommand().toLowerCase()); } } synchronized (frame.textinputfield) { frame.textinputfield.setText(""); } return; } // let the user choose another dir if (e.getSource().equals(frame.directorybutton)) { debugoutput("frame.directorybutton"); JFileChooser fc = new JFileChooser(); fc.setMultiSelectionEnabled(false); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); synchronized (frame.directorytextfield) { // we have to set current directory here because it gets lost when fc is lost fc.setCurrentDirectory(new File(frame.directorytextfield.getText())); } debugoutput("current dir: ".concat(fc.getCurrentDirectory().getAbsolutePath())); if (fc.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) { return; } String snewdirectory = fc.getSelectedFile().getAbsolutePath(); // append file.seperator if last character is not file.seperator (the user choosed a directory other than root) snewdirectory.concat(snewdirectory.endsWith(System.getProperty("file.separator")) ? "" : System.getProperty("file.separator")); File ftest = new File(snewdirectory); if (ftest.exists()) { if (ftest.isDirectory()) { synchronized (frame.directorytextfield) { frame.directorytextfield.setText(snewdirectory); } config.setProperty("savefolder", snewdirectory); debugoutput("new current dir: ".concat(fc.getCurrentDirectory().getAbsolutePath())); output("new current dir: ".concat(fc.getCurrentDirectory().getAbsolutePath())); } else { output("not a directory: ".concat(snewdirectory)); } } else { output("directory does not exist: ".concat(snewdirectory)); } return; } // let the user choose another download resolution if (e.getActionCommand().equals(JFCMainClient.frame.hdbutton.getActionCommand()) || e.getActionCommand().equals(JFCMainClient.frame.stdbutton.getActionCommand()) || e.getActionCommand().equals(JFCMainClient.frame.ldbutton.getActionCommand())) { debugoutput("trying: ".concat(e.getActionCommand())); output("trying: ".concat(e.getActionCommand().toUpperCase())); return; } // let the user choose another video format if (e.getActionCommand().equals(JFCMainClient.frame.mpgbutton.getActionCommand()) || e.getActionCommand().equals(JFCMainClient.frame.flvbutton.getActionCommand()) || e.getActionCommand().equals(JFCMainClient.frame.webmbutton.getActionCommand())) { debugoutput("trying: ".concat(e.getActionCommand())); output("trying: ".concat(e.getActionCommand().toUpperCase() .concat(" ".concat(isgerman() ? "(Dateien werden immer nach MIME-Typ benannt!)" : "(files will always be named according to MIME type!)")))); return; } if (e.getActionCommand().equals("quit")) { addTextToConsole(isgerman() ? "Programmende ausgewhlt - beende DownloadThreads, Vorgang kann eine Weile dauern!" : "quit requested - signaling donwload threads to terminate, this may take a while!"); // seems to have to effect: //JFCMainClient.frame.repaint(); JFCMainClient.shutdownAppl(); return; } debugoutput("unknown action. ".concat(e.getSource().toString())); output("unbekannte Aktion"); }
From source file:zz.filecollector.FileCollector.java
/** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor.//w ww. java 2 s .c o m */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { archiveDirChooser = new javax.swing.JFileChooser(); jLabel1 = new javax.swing.JLabel(); selectDestButton = new javax.swing.JButton(); archiveDirField = new javax.swing.JTextField(); jLabel2 = new javax.swing.JLabel(); srcDirField = new javax.swing.JTextField(); selectSrcButton = new javax.swing.JButton(); scanButton = new javax.swing.JButton(); startButton = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); infoArea = new javax.swing.JTextArea(); stopButton = new javax.swing.JButton(); actionBox = new javax.swing.JComboBox<>(); archiveDirChooser.setFileSelectionMode(javax.swing.JFileChooser.DIRECTORIES_ONLY); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jLabel1.setText(""); selectDestButton.setText("..."); selectDestButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { selectDestButtonActionPerformed(evt); } }); archiveDirField.setEditable(false); jLabel2.setText(""); srcDirField.setEditable(false); selectSrcButton.setText("..."); selectSrcButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { selectSrcButtonActionPerformed(evt); } }); scanButton.setText(""); scanButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { scanButtonActionPerformed(evt); } }); startButton.setText(""); startButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { startButtonActionPerformed(evt); } }); infoArea.setEditable(false); infoArea.setBackground(new java.awt.Color(240, 240, 240)); infoArea.setColumns(20); infoArea.setRows(5); jScrollPane1.setViewportView(infoArea); stopButton.setText("?"); stopButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { stopButtonActionPerformed(evt); } }); actionBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "", "?", "???" })); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jScrollPane1) .addGroup(layout.createSequentialGroup().addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel2) .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING)) .addComponent(scanButton, javax.swing.GroupLayout.Alignment.TRAILING)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(actionBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18).addComponent(startButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(stopButton)) .addGroup(layout.createSequentialGroup().addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(archiveDirField).addComponent(srcDirField, javax.swing.GroupLayout.DEFAULT_SIZE, 396, Short.MAX_VALUE)) .addGap(18, 18, 18) .addGroup(layout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent(selectDestButton) .addComponent(selectSrcButton)))))) .addGap(30, 30, 30))); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addGap(18, 18, 18).addGroup(layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel2) .addComponent(srcDirField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(selectSrcButton)).addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(archiveDirField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(selectDestButton)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(startButton).addComponent(stopButton)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(actionBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(scanButton))) .addGap(18, 18, 18) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 299, Short.MAX_VALUE) .addContainerGap())); pack(); }