本文共 1717 字,大约阅读时间需要 5 分钟。
package com.weep.mbcs.app;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
import com.weep.mbcs.conf.Constants;
/**
* 窗体菜单.
*
* @author weep
*
*/
public class MyMenu extends JFrame implements ActionListener {
/**
*
*/
private static final long serialVersionUID = 2923564817561058018L;
private JMenuBar jmb;
private JFrame jFrame;
public static ConfigDesk confDesk;
JMenu start, help, config;
JMenuItem copyright, explanation, exit, conf;
JTextArea t;
public MyMenu(JFrame jFrame) {
this.jFrame = jFrame;
this.menuInit();
jFrame.setJMenuBar(jmb);
}
public void menuInit() {
jmb = new JMenuBar();
start = new JMenu("开始");
help = new JMenu("帮助");
conf = new JMenuItem("设置收费标准");
exit = new JMenuItem("退出本系统");
explanation = new JMenuItem("说明");
copyright = new JMenuItem("版权");
jmb.add(start);
jmb.add(help);
start.add(conf);
start.add(exit);
help.add(explanation);
help.add(copyright);
conf.addActionListener(this);
exit.addActionListener(this);
explanation.addActionListener(this);
copyright.addActionListener(this);
t = new JTextArea();
t.setLineWrap(true);
}
public void actionPerformed(ActionEvent e) {
Object o = e.getSource();
JFileChooser f = new JFileChooser();
if (o == copyright) {
JOptionPane.showMessageDialog(this.jFrame, Constants.COPYRIGHT);
return;
}
if (o == explanation) {
JOptionPane.showMessageDialog(this.jFrame, Constants.HELP);
return;
}
if (o == conf) {
jFrame.setVisible(false);
confDesk = new ConfigDesk(jFrame);
return;
}
if (o == exit) {
System.exit(0);
}
}
}
转载地址:https://blog.csdn.net/weixin_33865450/article/details/114835978 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!