当前位置: 技术问答>java相关
请问如何通过JFileChooser类获取某个目录而非某个文件
来源: 互联网 发布时间:2015-04-05
本文导语: 如题, 如果JFileChooser类不能获得目录 那么我通过什么API可以实现类似JFileChooser的功能,要能获取目录 | setFileSelectionMode public void setFileSelectionMode(int mode) Sets the JFileChooser to allow the user t...
如题,
如果JFileChooser类不能获得目录
那么我通过什么API可以实现类似JFileChooser的功能,要能获取目录
如果JFileChooser类不能获得目录
那么我通过什么API可以实现类似JFileChooser的功能,要能获取目录
|
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 mode
See Also:
getFileSelectionMode()
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 mode
See Also:
getFileSelectionMode()
|
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);