import java.awt.event.*;
import javax.swing.*;public class OpenDialog extends JFrame implements ActionListener
{
JButton open = new JButton("打开");
JFileChooser chooser = new JFileChooser();
public OpenDialog()
{
super("打开");
setSize(300,350);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel pane = new JPanel();
open.addActionListener(this);
pane.add(open);
setContentPane(pane);
}
public void main(String[] args)
{
int state = chooser.showOpenDialog(null);
File file = chooser.getSeletedFile();
String s = "CANCELED";
if (file!=null && state==JFileChooser.APPPOVE_OPTION)
s=file.getPath();
JOptionPane.showMessageDialog(null,s);
}
}
这个程序是跟据一位网友给我的程序编出来的 但有点问题
首先 这个程序可以显示打开框 但框中的文件列表好像对双击反应很迟钝 有时根本就不反应
是不是我哪没有做对啊 能不能解决这个问题啊
import javax.swing.*;public class OpenDialog extends JFrame implements ActionListener
{
JButton open = new JButton("打开");
JFileChooser chooser = new JFileChooser();
public OpenDialog()
{
super("打开");
setSize(300,350);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel pane = new JPanel();
open.addActionListener(this);
pane.add(open);
setContentPane(pane);
}
public void main(String[] args)
{
int state = chooser.showOpenDialog(null);
File file = chooser.getSeletedFile();
String s = "CANCELED";
if (file!=null && state==JFileChooser.APPPOVE_OPTION)
s=file.getPath();
JOptionPane.showMessageDialog(null,s);
}
}
这个程序是跟据一位网友给我的程序编出来的 但有点问题
首先 这个程序可以显示打开框 但框中的文件列表好像对双击反应很迟钝 有时根本就不反应
是不是我哪没有做对啊 能不能解决这个问题啊
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货