public static File selectDir(Component parent) {

        // Create a file chooser
        final JFileChooser fc = new JFileChooser();
        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        // In response to a button click:
        int returnVal = fc.showOpenDialog(parent);

        if (returnVal == JFileChooser.APPROVE_OPTION) {
            return fc.getSelectedFile();
        }

        if (returnVal == JFileChooser.CANCEL_OPTION) {
            return null;
        }

        throw new FileException("file exception when select dir.");
    }