java中怎么实现在windows中那样点击打开菜单就能弹出选择文件的列表框? JFileChooser.javapublic int showDialog(Component parent, String approveButtonText) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 import java.awt.event.*;import javax.swing.*;public class Demo extends JFrame implements ActionListener { private JMenuBar _menuBar = new JMenuBar(); private JMenu _file = new JMenu("File"); private JMenuItem _open = new JMenuItem("Open"); //生成一个文件选择器,"c:\\"为直接打开C盘根目录 private JFileChooser _chooser = new JFileChooser("c:\\"); public Demo(String s) { super(s); _open.addActionListener(this); _file.add(_open); _menuBar.add(_file); this.setJMenuBar(_menuBar); this.setBounds(200,200,200,200); this.setDefaultCloseOperation(EXIT_ON_CLOSE); this.show(); } public void actionPerformed(ActionEvent e) { if(e.getSource() == _open) { //显示文件打开对话框,保存对话框为showSaveDialog _chooser.showOpenDialog(this); } } public static void main(String[] args) { new Demo("今天我有空"); }} java多态为什么 java 桌面程序应用观察者模式的MVC设计 javamail发送邮件问题 问个序列化的问题 JDK安装及环境变量设置的问题 如何把byte[]中的N个字符拷贝到另一个byte[]中? 一个很简单的多线程问题 为什么我用DataSourse访问不成功?帮帮小妹!! 强烈建议分类JAVA论坛,我的想法如下.... jbuilder的注册码 帮我看看这几个英文java的单词是什么意思啊 一个关于javamail的简单问题,送分,解决就行!
import javax.swing.*;public class Demo extends JFrame implements ActionListener {
private JMenuBar _menuBar = new JMenuBar();
private JMenu _file = new JMenu("File");
private JMenuItem _open = new JMenuItem("Open");
//生成一个文件选择器,"c:\\"为直接打开C盘根目录
private JFileChooser _chooser = new JFileChooser("c:\\"); public Demo(String s) {
super(s);
_open.addActionListener(this);
_file.add(_open);
_menuBar.add(_file);
this.setJMenuBar(_menuBar);
this.setBounds(200,200,200,200);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.show();
} public void actionPerformed(ActionEvent e) {
if(e.getSource() == _open) {
//显示文件打开对话框,保存对话框为showSaveDialog
_chooser.showOpenDialog(this);
}
} public static void main(String[] args) {
new Demo("今天我有空");
}
}