如题

解决方案 »

  1.   

    fc = new JFileChooser();
    fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
      

  2.   

    void chooseButtonDirectory_actionPerformed(ActionEvent e) {
            try {
                JFileChooser fileChooser = new JFileChooser();
                fileChooser.setFileSelectionMode(fileChooser.DIRECTORIES_ONLY);
                System.out.println("here is directories");            int n = fileChooser.showOpenDialog(this.getContentPane());
                if (n == fileChooser.APPROVE_OPTION) 
                 {                textFieldFileLocalDirectory.setText(fileChooser.getSelectedFile().getPath());
                   
                }
            } catch (Exception ex) {
                ex.printStackTrace();
            }    }