Swing使用JFileChooser【文件选择器】来选择目录的简单实现方法


JFileChooser chooser = new JFileChooser();
chooser.setApproveButtonText("确定");  
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);  //设置只选择目录
int returnVal = chooser.showOpenDialog(SwingWorkerUI.this); System.out.println("returnVal="+returnVal); if (returnVal == JFileChooser.APPROVE_OPTION) { System.out.println("You chose to open this file: "+ chooser.getSelectedFile().getName());


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM