📄 themain.java
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class theMain extends JFrame {
private JMenuBar jmb;
private JMenuItem add, show, about, exitframe;
private JMenu jm;
public theMain() {
super("Main");
jmb = new JMenuBar();
setJMenuBar(jmb);
jm = new JMenu("文件");
add = new JMenuItem("学生信息录入");
show = new JMenuItem("学生信息显示");
about = new JMenuItem("关于");
exitframe = new JMenuItem("退出");
add.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
JFrame newframe = new Add();
newframe.setSize(300,200);
newframe.setLocation(380,240);
newframe.setVisible(true);
} catch (Exception e3) {
System.out.println("调用Add,发生异常");
}
}
});
show.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
JFrame newframe = new Show();
newframe.setSize(400, 150);
newframe.setLocation(400,250);
newframe.setVisible(true);
} catch (Exception e2) {
System.out.println("调用Show,发生异常");
}
}
});
about.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JOptionPane.showMessageDialog(null, " 一个简单的学生信息存储程序");
}
});
exitframe.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
jm.add(add);
jm.add(show);
jm.addSeparator();
jm.add(about);
jm.add(exitframe);
jmb.add(jm);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -