輸入法獲取位置信息 JFileChooser中如何獲取絕對路徑?
JFileChooser中如何獲取絕對路徑?JFileChooser chooser=新建JFileChooser()如果(選擇器.showOpenDialog(幀)=JFileChooser.APP
JFileChooser中如何獲取絕對路徑?
JFileChooser chooser=新建JFileChooser()
如果(選擇器.showOpenDialog(幀)=JFileChooser.APPROVE選項)
{
文件fo=chooser.getSelectedFile文件()
字符串絕對路徑=獲取絕對路徑()
}
jFileChooser使用方法?
JFileChooserjFileChooser=newJFileChooser()inti=jFileChooser.showOpenDialog(null)如果(i==jFileChooser.APPROVE選項){//打開文件stringpath=jFileChooser.getSelectedFile文件().getAbsolutePath()字符串名稱=jFileChooser.getSelectedFile文件().getName()系統(tǒng)輸出打?。ā爱斍拔募窂剑骸甭窂健皀當前文件名:”名稱)}否則{系統(tǒng)輸出打?。ā拔催x擇文件”}
JFileFilter設置只顯示文件夾和指定后綴名的文件?
Jfilechooser filechooser=newjfilechooser()//創(chuàng)建一個文件選擇器文件選擇器.setCurrentDirectory(新文件()?!啊?/設置當前目錄filechooser.setAcceptAllFileFilterUsed已使用(false)//顯示所有文件filechooser.addChoosableFileFilter(新建)javax.swing.filechooser文件選擇器. filefilter(){public Boolean accept(file f){return true}public string getdescription(){return“所有文件(*)。*) "})