📄 main.java~23~
字号:
package sos;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Main extends JFrame implements ActionListener {
public Main() {
super("StudentOperationSystem");
setSize(600, 400);
Container content = getContentPane();
content.setBackground(Color.white);
// content.add("West", new Button("Modal"));
// add("East", new Button("Modeless"));
addWindowListener(new InnerDestroyer());
pack();
JMenu choice0 = new JMenu("文件");
choice0.setEnabled(true);
JMenuItem m0;
m0 = new JMenuItem("登录");
m0.addActionListener(this);
choice0.add(m0);
m0 = new JMenuItem("关于");
m0.addActionListener(this);
choice0.add(m0);
m0 = new JMenuItem("帮助");
m0.addActionListener(this);
choice0.add(m0);
m0 = new JMenuItem("退出");
m0.addActionListener(this);
choice0.add(m0);
JMenu choice1 = new JMenu("信息录入");
JMenuItem m1;
m1 = new JMenuItem("基本信息录入");
m1.addActionListener(this);
choice1.add(m1);
m1 = new JMenuItem("课程信息录入");
m1.addActionListener(this);
choice1.add(m1);
m1 = new JMenuItem("选课信息录入");
m1.addActionListener(this);
choice1.add(m1);
m1 = new JMenuItem("返回");
m1.addActionListener(this);
choice1.add(m1);
JMenu choice2 = new JMenu("统计查询");
JMenuItem m2;
m2 = new JMenuItem("基本信息查询");
m2.addActionListener(this);
choice2.add(m2);
m2 = new JMenuItem("课程信息查询");
m2.addActionListener(this);
choice2.add(m2);
m2 = new JMenuItem("选课信息查询");
m2.addActionListener(this);
choice2.add(m2);
m2 = new JMenuItem("返回");
m2.addActionListener(this);
choice2.add(m2);
JMenu choice3 = new JMenu("成绩查询");
JMenuItem m3;
m3 = new JMenuItem("开始成绩查询");
m3.addActionListener(this);
choice3.add(m3);
m3 = new JMenuItem("返回");
m3.addActionListener(this);
choice3.add(m3);
JMenu choice4 = new JMenu("成绩排序");
JMenuItem m4;
m4 = new JMenuItem("开始排序查询");
m4.addActionListener(this);
choice4.add(m4);
m4 = new JMenuItem("返回");
m4.addActionListener(this);
choice4.add(m4);
JMenuBar mBar = new JMenuBar();
mBar.add(choice0);
mBar.add(choice1);
mBar.add(choice2);
mBar.add(choice3);
mBar.add(choice4);
setJMenuBar(mBar);
show();
}
/* public void actionPerformed(Event evt, Object what) {
if ("登录".equals(what)) {
new MainDialog(this, true);
} else if ("Modeless".equals(what)) {
new MainDialog(this, false);
}
}
*/
public static void main(String[] args) {
new Main();
}
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("登录")) {
new MainDialog(this, true);
}
}
private class MainDialog extends Dialog {
public int offsetX, offsetY;
MainDialog(Frame frame, boolean modal) {
super(frame, modal);
setTitle(" Log In The System ");
add("Center", new Button("Quit"));
// offsetX += 20;
// offsetY += 20;
// move(offsetX, offsetY);
//pack();
show();
}
public boolean action(Event evt, Object what) {
if ("Quit".equals(what)) {
dispose();
return true;
}
return false;
}
}
private class InnerDestroyer extends WindowAdapter {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -