⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainframe.java

📁 基于JB的网络数据库系统开发
💻 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 + -