对话框获取目录、文件路径

 

代码
public File getFile(){
final JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
// JFileChooser.FILES_ONLY
// JFileChooser.DIRECTORIES_ONLY
int returnVal = fc.showOpenDialog(this);
File file_choosed
= fc.getSelectedFile();
return file_choosed;
}

 

 

 

posted @ 2010-06-27 22:18  xngeer  阅读(314)  评论(0编辑  收藏  举报