?? mainframe.java
字號:
package studentmanage;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2005</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/
public class MainFrame extends JFrame {
JPanel contentPane;
JMenuBar jMenuBar1 = new JMenuBar();
JMenu jMenuStudent = new JMenu();
JMenuItem jMenuStudentInsert = new JMenuItem();
JMenu jMenuCourse = new JMenu();
JMenuItem jMenuCourseInsert = new JMenuItem();
BorderLayout borderLayout1 = new BorderLayout();
JMenuItem jMenuStudentUpdate = new JMenuItem();
JMenuItem jMenuStudentQuery = new JMenuItem();
JLabel jLabel1 = new JLabel();
boolean status=false;
JMenu jMenuScore = new JMenu();
JMenu jMenuSystem = new JMenu();
JMenuItem jMenuSystemInsert = new JMenuItem();
JMenuItem jMenuSystemUpdate = new JMenuItem();
JMenuItem jMenuSystemQuery = new JMenuItem();
JMenuItem jMenuSystemExit = new JMenuItem();
JMenuItem jMenuCourseUpdate = new JMenuItem();
JMenuItem jMenuCourseQuery = new JMenuItem();
JMenuItem jMenuScoreInsert = new JMenuItem();
JMenuItem jMenuScoreUpdate = new JMenuItem();
JMenuItem jMenuScoreQuery = new JMenuItem();
//Construct the frame
public MainFrame() {
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
contentPane = (JPanel) this.getContentPane();
contentPane.setLayout(borderLayout1);
this.setSize(new Dimension(400, 300));
this.setTitle("學生成績管理系統");
jMenuStudent.setToolTipText("");
jMenuStudent.setText("學生管理");
jMenuStudentInsert.setText("學生信息錄入");
jMenuStudentInsert.addActionListener(new MainFrame_jMenuStudentInsert_ActionAdapter(this));
jMenuCourse.setText("課程管理");
jMenuCourseInsert.setText("課程信息錄入");
jMenuCourseInsert.addActionListener(new MainFrame_jMenuCourseInsert_ActionAdapter(this));
jMenuStudentUpdate.setText("學生信息修改");
jMenuStudentUpdate.addActionListener(new MainFrame_jMenuStudentUpdate_actionAdapter(this));
jMenuStudentQuery.setText("學生信息查詢");
jMenuStudentQuery.addActionListener(new MainFrame_jMenuStudentQuery_actionAdapter(this));
jLabel1.setFont(new java.awt.Font("Dialog", 0, 40));
jLabel1.setForeground(Color.red);
jLabel1.setVerifyInputWhenFocusTarget(true);
jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
jLabel1.setText("學生成績管理系統");
jMenuScore.setText("成績管理");
jMenuSystem.setText("系統");
jMenuSystemInsert.setText("學期設定");
jMenuSystemUpdate.setText("學期修改");
jMenuSystemUpdate.addActionListener(new MainFrame_jMenuSystemUpdate_actionAdapter(this));
jMenuSystemQuery.setText("學期查詢");
jMenuSystemExit.setText("系統退出");
jMenuCourseUpdate.setText("課程信息修改");
jMenuCourseQuery.setText("課程信息查詢");
jMenuScoreInsert.setText("課程成績錄入");
jMenuScoreInsert.addActionListener(new MainFrame_jMenuScoreInsert_actionAdapter(this));
jMenuScoreUpdate.setText("課程成績修改");
jMenuScoreUpdate.addActionListener(new MainFrame_jMenuScoreUpdate_actionAdapter(this));
jMenuScoreQuery.setText("課程成績查詢");
jMenuStudent.add(jMenuStudentInsert);
jMenuStudent.add(jMenuStudentUpdate);
jMenuStudent.add(jMenuStudentQuery);
jMenuCourse.add(jMenuCourseInsert);
jMenuCourse.add(jMenuCourseUpdate);
jMenuCourse.add(jMenuCourseQuery);
jMenuBar1.add(jMenuStudent);
jMenuBar1.add(jMenuCourse);
jMenuBar1.add(jMenuScore);
jMenuBar1.add(jMenuSystem);
contentPane.add(jLabel1, BorderLayout.CENTER);
jMenuSystem.add(jMenuSystemInsert);
jMenuSystem.add(jMenuSystemUpdate);
jMenuSystem.add(jMenuSystemQuery);
jMenuSystem.addSeparator();
jMenuSystem.add(jMenuSystemExit);
jMenuScore.add(jMenuScoreInsert);
jMenuScore.add(jMenuScoreUpdate);
jMenuScore.add(jMenuScoreQuery);
this.setJMenuBar(jMenuBar1);
}
public void jMenuStudentInsert_actionPerformed(ActionEvent e) {
StudentInsertPanel si=new StudentInsertPanel(this);
this.remove(this.getContentPane());
this.setContentPane(si);
this.show();
}
//Help | About action performed
public void jMenuCourseInsert_actionPerformed(ActionEvent e) {
}
//Overridden so we can exit when window is closed
protected void processWindowEvent(WindowEvent e) {
super.processWindowEvent(e);
if (e.getID() == WindowEvent.WINDOW_CLOSING) {
System.exit(0);
}
}
void jMenuStudentUpdate_actionPerformed(ActionEvent e) {
StudentDialog s1=new StudentDialog(this,"學生信息修改",true);
s1.setSize(320,250);
s1.show();
if (this.status==true){
//找到對應的記錄
this.status=false;
StudentUpdatePanel su=new StudentUpdatePanel(this,s1.studentid,s1.name,s1.sex);
this.remove(this.getContentPane());
this.setContentPane(su);
this.show();
}
}
void jMenuStudentQuery_actionPerformed(ActionEvent e) {
StudentDialog s1=new StudentDialog(this,"學生信息查詢",true);
s1.setSize(320,250);
s1.show();
if (this.status==true){
//找到對應的記錄
this.status=false;
StudentQueryPanel su=new StudentQueryPanel(this,s1.studentid,s1.name,s1.sex);
this.remove(this.getContentPane());
this.setContentPane(su);
this.show();
}
}
void jMenuScoreInsert_actionPerformed(ActionEvent e) {
ScoreDialog s1=new ScoreDialog(this,"成績錄入",true);
s1.setSize(525,300);
s1.show();
if(this.status){
status=false;
ScoreInsertPanel si=new ScoreInsertPanel(this,s1.semesterid,s1.courseid,s1.semestername,s1.coursename);
this.remove(this.getContentPane());
this.setContentPane(si);
this.show();
}
}
void jMenuSystemUpdate_actionPerformed(ActionEvent e) {
}
void jMenuScoreUpdate_actionPerformed(ActionEvent e) {
ScoreDialog s1=new ScoreDialog(this,"成績修改",true);
s1.setSize(525,300);
s1.show();
if(this.status){
status = false;
ScoreUpdatePanel si = new ScoreUpdatePanel(this, s1.semesterid,
s1.courseid, s1.semestername,
s1.coursename);
this.remove(this.getContentPane());
this.setContentPane(si);
this.show();
}
}
}
class MainFrame_jMenuStudentInsert_ActionAdapter implements ActionListener {
MainFrame adaptee;
MainFrame_jMenuStudentInsert_ActionAdapter( MainFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jMenuStudentInsert_actionPerformed(e);
}
}
class MainFrame_jMenuCourseInsert_ActionAdapter implements ActionListener {
MainFrame adaptee;
MainFrame_jMenuCourseInsert_ActionAdapter( MainFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jMenuCourseInsert_actionPerformed(e);
}
}
class MainFrame_jMenuStudentUpdate_actionAdapter implements java.awt.event.ActionListener {
MainFrame adaptee;
MainFrame_jMenuStudentUpdate_actionAdapter(MainFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jMenuStudentUpdate_actionPerformed(e);
}
}
class MainFrame_jMenuStudentQuery_actionAdapter implements java.awt.event.ActionListener {
MainFrame adaptee;
MainFrame_jMenuStudentQuery_actionAdapter(MainFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jMenuStudentQuery_actionPerformed(e);
}
}
class MainFrame_jMenuScoreInsert_actionAdapter implements java.awt.event.ActionListener {
MainFrame adaptee;
MainFrame_jMenuScoreInsert_actionAdapter(MainFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jMenuScoreInsert_actionPerformed(e);
}
}
class MainFrame_jMenuSystemUpdate_actionAdapter implements java.awt.event.ActionListener {
MainFrame adaptee;
MainFrame_jMenuSystemUpdate_actionAdapter(MainFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jMenuSystemUpdate_actionPerformed(e);
}
}
class MainFrame_jMenuScoreUpdate_actionAdapter implements java.awt.event.ActionListener {
MainFrame adaptee;
MainFrame_jMenuScoreUpdate_actionAdapter(MainFrame adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jMenuScoreUpdate_actionPerformed(e);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -