Example usage for javax.swing JFileChooser DIRECTORIES_ONLY

List of usage examples for javax.swing JFileChooser DIRECTORIES_ONLY

Introduction

In this page you can find the example usage for javax.swing JFileChooser DIRECTORIES_ONLY.

Prototype

int DIRECTORIES_ONLY

To view the source code for javax.swing JFileChooser DIRECTORIES_ONLY.

Click Source Link

Document

Instruction to display only directories.

Usage

From source file:forge.gui.ImportDialog.java

@SuppressWarnings("serial")
public ImportDialog(final String forcedSrcDir, final Runnable onDialogClose) {
    this.forcedSrcDir = forcedSrcDir;

    _topPanel = new FPanel(new MigLayout("insets dialog, gap 0, center, wrap, fill"));
    _topPanel.setOpaque(false);//from   w  w  w.j av  a2 s . c om
    _topPanel.setBackgroundTexture(FSkin.getIcon(FSkinProp.BG_TEXTURE));

    isMigration = !StringUtils.isEmpty(forcedSrcDir);

    // header
    _topPanel.add(new FLabel.Builder().text((isMigration ? "Migrate" : "Import") + " profile data").fontSize(15)
            .build(), "center");

    // add some help text if this is for the initial data migration
    if (isMigration) {
        final FPanel blurbPanel = new FPanel(new MigLayout("insets panel, gap 10, fill"));
        blurbPanel.setOpaque(false);
        final JPanel blurbPanelInterior = new JPanel(
                new MigLayout("insets dialog, gap 10, center, wrap, fill"));
        blurbPanelInterior.setOpaque(false);
        blurbPanelInterior.add(new FLabel.Builder().text("<html><b>What's this?</b></html>").build(),
                "growx, w 50:50:");
        blurbPanelInterior.add(new FLabel.Builder()
                .text("<html>Over the last several years, people have had to jump through a lot of hoops to"
                        + " update to the most recent version.  We hope to reduce this workload to a point where a new"
                        + " user will find that it is fairly painless to update.  In order to make this happen, Forge"
                        + " has changed where it stores your data so that it is outside of the program installation directory."
                        + "  This way, when you upgrade, you will no longer need to import your data every time to get things"
                        + " working.  There are other benefits to having user data separate from program data, too, and it"
                        + " lays the groundwork for some cool new features.</html>")
                .build(), "growx, w 50:50:");
        blurbPanelInterior.add(
                new FLabel.Builder().text("<html><b>So where's my data going?</b></html>").build(),
                "growx, w 50:50:");
        blurbPanelInterior.add(new FLabel.Builder().text(
                "<html>Forge will now store your data in the same place as other applications on your system."
                        + "  Specifically, your personal data, like decks, quest progress, and program preferences will be"
                        + " stored in <b>" + ForgeConstants.USER_DIR
                        + "</b> and all downloaded content, such as card pictures,"
                        + " skins, and quest world prices will be under <b>" + ForgeConstants.CACHE_DIR
                        + "</b>.  If, for whatever"
                        + " reason, you need to set different paths, cancel out of this dialog, exit Forge, and find the <b>"
                        + ForgeConstants.PROFILE_TEMPLATE_FILE
                        + "</b> file in the program installation directory.  Copy or rename" + " it to <b>"
                        + ForgeConstants.PROFILE_FILE
                        + "</b> and edit the paths inside it.  Then restart Forge and use"
                        + " this dialog to move your data to the paths that you set.  Keep in mind that if you install a future"
                        + " version of Forge into a different directory, you'll need to copy this file over so Forge will know"
                        + " where to find your data.</html>")
                .build(), "growx, w 50:50:");
        blurbPanelInterior.add(new FLabel.Builder().text(
                "<html><b>Remember, your data won't be available until you complete this step!</b></html>")
                .build(), "growx, w 50:50:");

        final FScrollPane blurbScroller = new FScrollPane(blurbPanelInterior, true,
                ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        blurbPanel.add(blurbScroller, "hmin 150, growy, growx, center, gap 0 0 5 5");
        _topPanel.add(blurbPanel, "gap 10 10 20 0, growy, growx, w 50:50:");
    }

    // import source widgets
    final JPanel importSourcePanel = new JPanel(new MigLayout("insets 0, gap 10"));
    importSourcePanel.setOpaque(false);
    importSourcePanel.add(new FLabel.Builder().text("Import from:").build());
    _txfSrc = new FTextField.Builder().readonly().build();
    importSourcePanel.add(_txfSrc, "pushx, growx");
    _btnChooseDir = new FLabel.ButtonBuilder().text("Choose directory...").enabled(!isMigration).build();
    final JFileChooser _fileChooser = new JFileChooser();
    _fileChooser.setMultiSelectionEnabled(false);
    _fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    _btnChooseDir.setCommand(new UiCommand() {
        @Override
        public void run() {
            // bring up a file open dialog and, if the OK button is selected, apply the filename
            // to the import source text field
            if (JFileChooser.APPROVE_OPTION == _fileChooser.showOpenDialog(JOptionPane.getRootFrame())) {
                final File f = _fileChooser.getSelectedFile();
                if (!f.canRead()) {
                    FOptionPane.showErrorDialog("Cannot access selected directory (Permission denied).");
                } else {
                    _txfSrc.setText(f.getAbsolutePath());
                }
            }
        }
    });
    importSourcePanel.add(_btnChooseDir, "h pref+8!, w pref+12!");

    // add change handler to the import source text field that starts up a
    // new analyzer.  it also interacts with the current active analyzer,
    // if any, to make sure it cancels out before the new one is initiated
    _txfSrc.getDocument().addDocumentListener(new DocumentListener() {
        boolean _analyzerActive; // access synchronized on _onAnalyzerDone
        String prevText;

        private final Runnable _onAnalyzerDone = new Runnable() {
            @Override
            public synchronized void run() {
                _analyzerActive = false;
                notify();
            }
        };

        @Override
        public void removeUpdate(final DocumentEvent e) {
        }

        @Override
        public void changedUpdate(final DocumentEvent e) {
        }

        @Override
        public void insertUpdate(final DocumentEvent e) {
            // text field is read-only, so the only time this will get updated
            // is when _btnChooseDir does it
            final String text = _txfSrc.getText();
            if (text.equals(prevText)) {
                // only restart the analyzer if the directory has changed
                return;
            }
            prevText = text;

            // cancel any active analyzer
            _cancel = true;

            if (!text.isEmpty()) {
                // ensure we don't get two instances of this function running at the same time
                _btnChooseDir.setEnabled(false);

                // re-disable the start button.  it will be enabled if the previous analyzer has
                // already successfully finished
                _btnStart.setEnabled(false);

                // we have to wait in a background thread since we can't block in the GUI thread
                final SwingWorker<Void, Void> analyzerStarter = new SwingWorker<Void, Void>() {
                    @Override
                    protected Void doInBackground() throws Exception {
                        // wait for active analyzer (if any) to quit
                        synchronized (_onAnalyzerDone) {
                            while (_analyzerActive) {
                                _onAnalyzerDone.wait();
                            }
                        }
                        return null;
                    }

                    // executes in gui event loop thread
                    @Override
                    protected void done() {
                        _cancel = false;
                        synchronized (_onAnalyzerDone) {
                            // this will populate the panel with data selection widgets
                            final _AnalyzerUpdater analyzer = new _AnalyzerUpdater(text, _onAnalyzerDone,
                                    isMigration);
                            analyzer.run();
                            _analyzerActive = true;
                        }
                        if (!isMigration) {
                            // only enable the directory choosing button if this is not a migration dialog
                            // since in that case we're permanently locked to the starting directory
                            _btnChooseDir.setEnabled(true);
                        }
                    }
                };
                analyzerStarter.execute();
            }
        }
    });
    _topPanel.add(importSourcePanel, "gaptop 20, pushx, growx");

    // prepare import selection panel (will be cleared and filled in later by an analyzer)
    _selectionPanel = new JPanel();
    _selectionPanel.setOpaque(false);
    _topPanel.add(_selectionPanel, "growx, growy, gaptop 10");

    // action button widgets
    final Runnable cleanup = new Runnable() {
        @Override
        public void run() {
            SOverlayUtils.hideOverlay();
        }
    };
    _btnStart = new FButton("Start import");
    _btnStart.setEnabled(false);
    _btnCancel = new FButton("Cancel");
    _btnCancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(final ActionEvent e) {
            _cancel = true;
            cleanup.run();
            if (null != onDialogClose) {
                onDialogClose.run();
            }
        }
    });

    final JPanel southPanel = new JPanel(new MigLayout("ax center"));
    southPanel.setOpaque(false);
    southPanel.add(_btnStart, "center, w pref+144!, h pref+12!");
    southPanel.add(_btnCancel, "center, w pref+144!, h pref+12!, gap 72");
    _topPanel.add(southPanel, "growx");
}

From source file:de.evaluationtool.gui.EvaluationFrameActionListener.java

private void savePositiveNegativeNT() throws IOException {
    JFileChooser chooser = new JFileChooser("Save as multiple nt files. Please choose a directory");
    chooser.setCurrentDirectory(frame.defaultDirectory);
    if (geoFile != null) {
        chooser.setCurrentDirectory(geoFile);
    }//from   w  w  w .j  a va  2 s .  c  o  m
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setAcceptAllFileFilterUsed(false);

    int returnVal = chooser.showSaveDialog(frame);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        frame.savePositiveNegativeNT(chooser.getSelectedFile());
    }
}

From source file:com.jvms.i18neditor.Editor.java

public void showImportDialog() {
    String path = null;/*from   w  ww .  ja v  a2 s  .c om*/
    if (resourcesDir != null) {
        path = resourcesDir.toString();
    }
    JFileChooser fc = new JFileChooser(path);
    fc.setDialogTitle(MessageBundle.get("dialogs.import.title"));
    fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    int result = fc.showOpenDialog(this);
    if (result == JFileChooser.APPROVE_OPTION) {
        importResources(Paths.get(fc.getSelectedFile().getPath()));
    }
}

From source file:Compare.java

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    // TODO add your handling code here:

    String userDir = System.getProperty("user.home");
    JFileChooser folder = new JFileChooser(userDir + "/Desktop");
    folder.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    folder.setFileSelectionMode(JFileChooser.FILES_ONLY);
    FileNameExtensionFilter xmlfilter = new FileNameExtensionFilter("Excel Files  (*.xls)", "xls");
    folder.setFileFilter(xmlfilter);/*w w w  . jav a  2s.  co  m*/
    int returnvalue = folder.showSaveDialog(this);

    File myfolder = null;
    if (returnvalue == JFileChooser.APPROVE_OPTION) {
        myfolder = folder.getSelectedFile();
        //            System.out.println(myfolder);         
    }

    if (myfolder != null) {
        JOptionPane.showMessageDialog(null, "The current choosen file directory is : " + myfolder);

        listofFiles1(myfolder);
        sortByName1();
    }

    DefaultTableModel model = (DefaultTableModel) FileDetails1.getModel();

    int count = 1;

    System.out.println(filenames2.size());
    for (Files filename : filenames2) {
        String size = Long.toString(filename.Filesize) + "Bytes";
        model.addRow(new Object[] { count++, filename.Filename, size, filename.FileLocation });
    }

}

From source file:com.xyphos.vmtgen.GUI.java

private void btnRootFolderBrowseActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btnRootFolderBrowseActionPerformed
    JFileChooser fc = new JFileChooser();
    fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    int result = fc.showOpenDialog(this);
    if (JFileChooser.APPROVE_OPTION == result) {
        rootPath = fc.getSelectedFile().getAbsolutePath();
        txtRootFolder.setText(rootPath);
        preferences.put(pref_ROOT, rootPath);
        showTextureFiles();//from w w  w. ja  va 2 s . c om
    }
}

From source file:edu.harvard.mcz.imagecapture.jobs.JobAllImageFilesScan.java

@Override
public void start() {
    startTime = new Date();
    Singleton.getSingletonInstance().getJobList().addJob((RunnableJob) this);
    runStatus = RunStatus.STATUS_RUNNING;
    File imagebase = null; // place to start the scan from, imagebase directory for SCAN_ALL
    startPoint = null;/*from w  ww  .j  av  a 2 s  . c  o m*/
    // If it isn't null, retrieve the image base directory from properties, and test for read access.
    if (Singleton.getSingletonInstance().getProperties().getProperties()
            .getProperty(ImageCaptureProperties.KEY_IMAGEBASE) == null) {
        JOptionPane.showMessageDialog(Singleton.getSingletonInstance().getMainFrame(),
                "Can't start scan.  Don't know where images are stored.  Set imagbase property.", "Can't Scan.",
                JOptionPane.ERROR_MESSAGE);
    } else {
        imagebase = new File(Singleton.getSingletonInstance().getProperties().getProperties()
                .getProperty(ImageCaptureProperties.KEY_IMAGEBASE));
        if (imagebase != null) {
            if (imagebase.canRead()) {
                startPoint = imagebase;
            } else {
                // If it can't be read, null out imagebase
                imagebase = null;
            }
        }
        if (scan == SCAN_SPECIFIC && startPointSpecific != null && startPointSpecific.canRead()) {
            // A scan start point has been provided, don't launch a dialog.
            startPoint = startPointSpecific;
        }
        if (imagebase == null || scan == SCAN_SELECT) {
            // launch a file chooser dialog to select the directory to scan
            final JFileChooser fileChooser = new JFileChooser();
            fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            if (scan == SCAN_SELECT && startPointSpecific != null && startPointSpecific.canRead()) {
                fileChooser.setCurrentDirectory(startPointSpecific);
            } else {
                if (Singleton.getSingletonInstance().getProperties().getProperties()
                        .getProperty(ImageCaptureProperties.KEY_LASTPATH) != null) {
                    fileChooser.setCurrentDirectory(new File(Singleton.getSingletonInstance().getProperties()
                            .getProperties().getProperty(ImageCaptureProperties.KEY_LASTPATH)));
                }
            }
            int returnValue = fileChooser.showOpenDialog(Singleton.getSingletonInstance().getMainFrame());
            if (returnValue == JFileChooser.APPROVE_OPTION) {
                File file = fileChooser.getSelectedFile();
                log.debug("Selected base directory: " + file.getName() + ".");
                startPoint = file;
            } else {
                //TODO: handle error condition
                log.error("Directory selection cancelled by user.");
            }
            //TODO: Filechooser to pick path, then save (if SCAN_ALL) imagebase property. 
            //Perhaps.  Might be undesirable behavior.
            //Probably better to warn that imagebase is null;
        }

        // TODO: Check that startPoint is or is within imagebase.
        // Check that fileToCheck is within imagebase.
        if (!ImageCaptureProperties.isInPathBelowBase(startPoint)) {
            String base = Singleton.getSingletonInstance().getProperties().getProperties()
                    .getProperty(ImageCaptureProperties.KEY_IMAGEBASE);
            log.error("Tried to scan directory (" + startPoint.getPath() + ") outside of base image directory ("
                    + base + ")");
            String message = "Can't scan and database files outside of base image directory (" + base + ")";
            JOptionPane.showMessageDialog(Singleton.getSingletonInstance().getMainFrame(), message,
                    "Can't Scan outside image base directory.", JOptionPane.YES_NO_OPTION);
        } else {

            // run in separate thread and allow cancellation and status reporting

            // walk through directory tree

            if (!startPoint.canRead()) {
                JOptionPane.showMessageDialog(Singleton.getSingletonInstance().getMainFrame(),
                        "Can't start scan.  Unable to read selected directory: " + startPoint.getPath(),
                        "Can't Scan.", JOptionPane.YES_NO_OPTION);
            } else {
                Singleton.getSingletonInstance().getMainFrame()
                        .setStatusMessage("Scanning " + startPoint.getPath());
                Counter counter = new Counter();
                // count files to scan
                countFiles(startPoint, counter);
                setPercentComplete(0);
                Singleton.getSingletonInstance().getMainFrame().notifyListener(runStatus, this);
                counter.incrementDirectories();
                // scan
                if (runStatus != RunStatus.STATUS_TERMINATED) {
                    checkFiles(startPoint, counter);
                }
                // report
                String report = "Scanned " + counter.getDirectories() + " directories.\n";
                report += "Created thumbnails in " + thumbnailCounter + " directories";
                if (thumbnailCounter == 0) {
                    report += " (May still be in progress)";
                }
                report += ".\n";
                if (startPointSpecific == null) {
                    report += "Starting with the base image directory (Preprocess All).\n";
                } else {
                    report += "Starting with " + startPoint.getName() + " (" + startPoint.getPath() + ")\n";
                    report += "First file: " + firstFile + " Last File: " + lastFile + "\n";
                }
                report += "Scanned  " + counter.getFilesSeen() + " files.\n";
                report += "Created  " + counter.getFilesDatabased() + " new image records.\n";
                if (counter.getFilesUpdated() > 0) {
                    report += "Updated  " + counter.getFilesUpdated() + " image records.\n";

                }
                report += "Created  " + counter.getSpecimens() + " new specimen records.\n";
                if (counter.getSpecimensUpdated() > 0) {
                    report += "Updated  " + counter.getSpecimensUpdated() + " specimen records.\n";

                }
                report += "Found " + counter.getFilesFailed() + " files with problems.\n";
                //report += counter.getErrors();
                Singleton.getSingletonInstance().getMainFrame().setStatusMessage("Preprocess scan complete");
                setPercentComplete(100);
                Singleton.getSingletonInstance().getMainFrame().notifyListener(runStatus, this);
                RunnableJobReportDialog errorReportDialog = new RunnableJobReportDialog(
                        Singleton.getSingletonInstance().getMainFrame(), report, counter.getErrors(),
                        "Preprocess Results");
                errorReportDialog.setVisible(true);
                //JOptionPane.showMessageDialog(Singleton.getSingletonInstance().getMainFrame(), report, "Preprocess complete", JOptionPane.ERROR_MESSAGE);
            } // can read directory
        }

        SpecimenLifeCycle sls = new SpecimenLifeCycle();
        Singleton.getSingletonInstance().getMainFrame().setCount(sls.findSpecimenCount());
    } // Imagebase isn't null
    done();
}

From source file:de.evaluationtool.gui.EvaluationFrameActionListener.java

private void loadPositiveNegativeNT() throws IOException {
    JFileChooser chooser = new JFileChooser("Load multiple nt files. Please choose a directory");
    chooser.setCurrentDirectory(frame.defaultDirectory);
    if (geoFile != null) {
        chooser.setCurrentDirectory(geoFile);
    }/* w  ww .  ja  v a 2 s  .  c o  m*/
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setAcceptAllFileFilterUsed(false);

    int returnVal = chooser.showSaveDialog(frame);
    if (returnVal == JFileChooser.APPROVE_OPTION) {
        System.out.print("Loading...");
        frame.loadPositiveNegativeNT(chooser.getSelectedFile());
        System.out.println("loading finished.");
    }
}

From source file:de.hu_berlin.german.korpling.annis.kickstarter.ImportDialog.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./*from   www . ja v a  2 s .  c  om*/
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    fileChooser = new javax.swing.JFileChooser();
    jLabel1 = new javax.swing.JLabel();
    txtInputDir = new javax.swing.JTextField();
    btCancel = new javax.swing.JButton();
    btOk = new javax.swing.JButton();
    btSearchInputDir = new javax.swing.JButton();
    pbImport = new javax.swing.JProgressBar();
    jLabel2 = new javax.swing.JLabel();
    lblStatus = new javax.swing.JLabel();
    pbCorpus = new javax.swing.JProgressBar();
    lblCurrentCorpus = new javax.swing.JLabel();

    fileChooser.setFileSelectionMode(javax.swing.JFileChooser.DIRECTORIES_ONLY);

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setTitle("Import - ANNIS Kickstarter");
    setLocationByPlatform(true);

    jLabel1.setText("Directory to import:");

    btCancel.setMnemonic('c');
    btCancel.setText("Cancel");
    btCancel.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btCancelActionPerformed(evt);
        }
    });

    btOk.setMnemonic('o');
    btOk.setText("Ok");
    btOk.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btOkActionPerformed(evt);
        }
    });

    btSearchInputDir.setText("...");
    btSearchInputDir.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            btSearchInputDirActionPerformed(evt);
        }
    });

    jLabel2.setText("status:");

    lblStatus.setText("...");

    lblCurrentCorpus.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
    lblCurrentCorpus.setText("Please select corpus for import!");

    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(pbImport, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addGroup(layout.createSequentialGroup().addComponent(jLabel1)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(txtInputDir, javax.swing.GroupLayout.DEFAULT_SIZE, 462,
                                            Short.MAX_VALUE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(btSearchInputDir, javax.swing.GroupLayout.PREFERRED_SIZE, 36,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup().addComponent(jLabel2)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(lblStatus, javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                    .addComponent(lblCurrentCorpus, javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(pbCorpus, javax.swing.GroupLayout.PREFERRED_SIZE,
                                            javax.swing.GroupLayout.DEFAULT_SIZE,
                                            javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                    .addComponent(btCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 105,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(btOk, javax.swing.GroupLayout.PREFERRED_SIZE, 105,
                                            javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout
                    .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel1)
                    .addComponent(txtInputDir, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btSearchInputDir))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(pbCorpus, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(lblCurrentCorpus, javax.swing.GroupLayout.DEFAULT_SIZE,
                                    javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGap(7, 7, 7)
                    .addComponent(pbImport, javax.swing.GroupLayout.PREFERRED_SIZE,
                            javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2).addComponent(lblStatus,
                                    javax.swing.GroupLayout.PREFERRED_SIZE, 15,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
                            javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btCancel).addComponent(btOk))
                    .addContainerGap()));

    pack();
}

From source file:com.xyphos.vmtgen.GUI.java

private void btnWorkFolderBrowseActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btnWorkFolderBrowseActionPerformed
    File dir = new File(rootPath);
    JFileChooser fc = new JFileChooser(dir);
    fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    int result = fc.showOpenDialog(this);
    if (JFileChooser.APPROVE_OPTION == result) {
        workPath = fc.getSelectedFile().getAbsolutePath();
        txtWorkFolder.setText(workPath);
        preferences.put(pref_WORK, workPath);
        showTextureFiles();//from ww w .j av  a2s .  c  om
    }
}

From source file:de.dmarcini.submatix.pclogger.gui.ProgramProperetysDialog.java

/**
 * Das exportverzeichis auswhlen Project: SubmatixBTForPC Package: de.dmarcini.submatix.pclogger.gui
 * //  ww  w.  j  a v  a  2 s  .  c o m
 * @author Dirk Marciniak (dirk_marciniak@arcor.de) Stand: 28.08.2012
 */
private void chooseExportDir() {
    JFileChooser fileChooser;
    int retVal;
    //
    // Einen Dateiauswahldialog Creieren
    //
    fileChooser = new JFileChooser();
    fileChooser.setLocale(Locale.getDefault());
    fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    fileChooser.setDialogTitle(fileChooserExportDirTitle);
    fileChooser.setDialogType(JFileChooser.CUSTOM_DIALOG);
    fileChooser.setApproveButtonToolTipText(approveDirButtonTooltip);
    // das existierende Verzeichnis voreinstellen
    fileChooser.setSelectedFile(SpxPcloggerProgramConfig.exportDir);
    retVal = fileChooser.showDialog(this, approveDirButtonText);
    // Mal sehen, was der User gewollt hat
    if (retVal == JFileChooser.APPROVE_OPTION) {
        // Ja, ich wollte das so
        exportDirTextField.setText(fileChooser.getSelectedFile().getAbsolutePath());
        wasChangedParameter = true;
    }
}