文件选择对话框
来源:互联网 发布:做淘宝亏本冲量可以? 编辑:程序博客网 时间:2024/05/27 20:49
import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.File;import javax.swing.JButton;import javax.swing.JFileChooser;import javax.swing.JFrame;import javax.swing.JLabel;@SuppressWarnings("serial")public class Filechooser extends JFrame implements ActionListener{JButton open=null;public static void main (String[] args){new Filechooser();//构造一个指向用户的默认目录Filechooser}public Filechooser(){open=new JButton("打开");this.add(open);this.setBounds(100,100,100,100);this.setVisible(true);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);open.addActionListener(this);}public void actionPerformed(ActionEvent e){JFileChooser j=new JFileChooser();j.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);//设置Filechooserj.showDialog(new JLabel(),"选择");// 弹出具有自定义 approve 按钮的自定义文件选择器对话框File file=j.getSelectedFile();if(file.isDirectory()){System.out.println("文件夹 "+file.getAbsolutePath());}else if(file.isFile()){System.out.println("文件夹 "+file.getAbsolutePath());}System.out.println(j.getSelectedFile().getName());}}
0 0
- 选择目录对话框和选择文件对话框
- 选择目录对话框和选择文件对话框
- 选择目录对话框和选择文件对话框
- 选择目录对话框和选择文件对话框
- vs2010MFC选择文件对话框,选择目录对话框
- 选择目录对话框,选择文件对话框
- 选择目录对话框和选择文件对话框
- 选择目录对话框和选择文件对话框
- 选择文件的对话框
- 文件对话框多重选择
- CFileDialog文件选择对话框
- CFileDialog文件选择对话框
- Java文件选择对话框
- 打开->选择文件对话框
- 选择文件对话框
- 打开选择文件对话框
- MFC 文件选择对话框
- 文件选择对话框
- hibernate 映射关系—关系映射(一对多)
- Oracle 11g行列互换pivot和unpivot说明
- 端口映射实现手机做服务器
- hibernate 映射关系—关系映射(一对一)
- argument 与 parameter
- 文件选择对话框
- Servlet生命周期与工作原理
- hibernate使用总结(1)
- 5.19
- cmake编译QT5串口通信
- Requests: HTTP for Humans
- Oracle Merge 使用
- 53.Maximum Subarray&连续子数组的最大和
- java多线程编程