setFileSelectionMode
public void setFileSelectionMode(int mode)Sets the JFileChooser to allow the user to just select files, just select directories, or select both files and directories. The default is JFilesChooser.FILES_ONLY.
Parameters:
mode - the type of files to be displayed: 
JFileChooser.FILES_ONLY 
JFileChooser.DIRECTORIES_ONLY 
JFileChooser.FILES_AND_DIRECTORIES 
Throws:
IllegalArgumentException - if mode is an illegal Dialog modeJFileChooser是可以即选文件又选目录的,用这个方法就行了。多看看API文档吧