1 package com.soft.test; 2 3 import javax.swing.*; 4 import javax.swing.filechooser.*; 5 import java.awt.event.*; 6 import java.io.FileFilter; 7 8 public class SplashDemo extends JFrame implements ActionListener { 9 private JButton jb = null;10 11 public SplashDemo() {12 jb = new JButton("打开");13 jb.addActionListener(this);14 15 this.add(jb);16 this.setSize(400, 300);17 this.setResizable(false);18 this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);19 this.setVisible(true);20 }21 22 public static void main(String[] args) {23 24 SplashDemo s = new SplashDemo();25 }26 27 public void actionPerformed(ActionEvent e) {28 JFileChooser jf = new JFileChooser();29 jf.setToolTipText("打开");30 FileNameExtensionFilter ff = new FileNameExtensionFilter(31 "图像文件(jpg/gif)", "jpg", "jpeg", "gif");32 jf.setFileFilter(ff);33 jf.showOpenDialog(this);34 35 }36 37 }