标签:pen [] 打开文件 sel png isp static gets setfile
package com.zyq; import javax.swing.JFileChooser; import javax.swing.filechooser.FileNameExtensionFilter; public class XuanMulu { //打开文件目录对话框的方法,直接运行即可 public static void main(String[] args) { // TODO Auto-generated method stub JFileChooser chooser = new JFileChooser(); FileNameExtensionFilter filter = new FileNameExtensionFilter( "JPG & GIF Images", "jpg", "gif"); chooser.setFileFilter(filter); int returnVal = chooser.showOpenDialog(chooser); if(returnVal == JFileChooser.APPROVE_OPTION) { System.out.println("You chose to open this file: " + chooser.getSelectedFile().getName());//clooser.getSelectedFile().getName()为点击的文件名 } } }//运行后如图
标签:pen [] 打开文件 sel png isp static gets setfile
原文地址:https://www.cnblogs.com/hssmyyq/p/10178888.html