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

📄 zsstudentapp.java

📁 学生管理(部分源代码仅供参考
💻 JAVA
字号:
package zhangyan34;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.util.Hashtable;
import java.io.*;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JMenuBar;
import javax.swing.event.AncestorEvent;
import javax.swing.event.AncestorListener;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JTextArea;
import java.awt.*;
import javax.swing.JLabel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class zsStudentApp extends JFrame {
    JPanel contentPane;
    BorderLayout borderLayout1 = new BorderLayout();
    JMenuBar jMenuBar1 = new JMenuBar();
    JMenu jMenu1 = new JMenu();
    JMenuItem jMenuItem1 = new JMenuItem();
    JMenuItem jMenuItem2 = new JMenuItem();
    JMenuItem jMenuItem3 = new JMenuItem();
    JMenuItem jMenuItem4 = new JMenuItem();
    JLabel jLabel1 = new JLabel();
    zsStudentApp sframe=null;
    Hashtable info=null;
    File file=null;
    public zsStudentApp() {
        try {
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }

    info=new Hashtable(); // 将Hashtable类的对象info实例化,学生的信息都存在info
// 对象中
    file=new File("zs.txt"); // 将File类的对象file实例化,初始化的文件名为zs.txt
                       //(请将文件名改为自己的姓名首字母)
    if(!file.exists()){   // 如果该文件不存在,则创建存放散列表info的文件zs.txt
      try{
        FileOutputStream out=new FileOutputStream(file);
        ObjectOutputStream objectOut=new ObjectOutputStream(out);
        objectOut.writeObject(info);
        objectOut.close();
        out.close();
      }
      catch(IOException e)
          {
          }
    }

    }

    /**
     * Component initialization.
     *
     * @throws java.lang.Exception
     */
    private void jbInit() throws Exception {
        contentPane = (JPanel) getContentPane();
        contentPane.setLayout(borderLayout1);
        this.setJMenuBar(jMenuBar1);
        setSize(new Dimension(400, 300));
        setTitle("学生管理系统");
        contentPane.addAncestorListener(new
                zsStudentApp_contentPane_ancestorAdapter(this));
        jMenu1.setText("菜单选项");
        jMenuItem1.setText("录入学生基本信息");
        jMenuItem1.addActionListener(new zsStudentApp_jMenuItem1_actionAdapter(this));
        jMenuItem2.setText("修改学生基本信息");
        jMenuItem2.addActionListener(new zsStudentApp_jMenuItem2_actionAdapter(this));
        jMenuItem3.setText("查询学生基本信息");
        jMenuItem3.addActionListener(new zsStudentApp_jMenuItem3_actionAdapter(this));
        jMenuItem4.setText("删除学生基本信息");
        jMenuItem4.addActionListener(new zsStudentApp_jMenuItem4_actionAdapter(this));
        jLabel1.setFont(new java.awt.Font("Dialog", Font.PLAIN, 20));
        jLabel1.setText("欢迎使用学生管理系统");
        jMenuBar1.addAncestorListener(new
                                      zsStudentApp_jMenuBar1_ancestorAdapter(this));
        jMenuBar1.add(jMenu1);
        jMenu1.add(jMenuItem1);
        jMenu1.add(jMenuItem2);
        jMenu1.add(jMenuItem3);
        jMenu1.add(jMenuItem4);
        contentPane.add(jLabel1, java.awt.BorderLayout.CENTER);
    }

    public void contentPane_ancestorAdded(AncestorEvent event) {

    }

    public void jMenuBar1_ancestorAdded(AncestorEvent event) {

    }

    public void jMenuItem3_actionPerformed(ActionEvent e) {
        zyInquest   iframe = new  zyInquest(file);
                   iframe.setVisible(true);
    }

    public void jMenuItem1_actionPerformed(ActionEvent e) {
        zyStudentSituation   sframe=new zyStudentSituation(file);
                   sframe.setVisible(true);
    }

    public void jMenuItem2_actionPerformed(ActionEvent e) {
        zymodifysituation   mframe=new zymodifysituation(file);
                   mframe.setVisible(true);
    }

    public void jMenuItem4_actionPerformed(ActionEvent e) {
         zyDelete dframe=new zyDelete(file);
          dframe.setVisible(true);
    }
}


class zsStudentApp_jMenuItem4_actionAdapter implements ActionListener {
    private zsStudentApp adaptee;
    zsStudentApp_jMenuItem4_actionAdapter(zsStudentApp adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jMenuItem4_actionPerformed(e);
    }
}


class zsStudentApp_jMenuItem2_actionAdapter implements ActionListener {
    private zsStudentApp adaptee;
    zsStudentApp_jMenuItem2_actionAdapter(zsStudentApp adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jMenuItem2_actionPerformed(e);
    }
}


class zsStudentApp_jMenuItem1_actionAdapter implements ActionListener {
    private zsStudentApp adaptee;
    zsStudentApp_jMenuItem1_actionAdapter(zsStudentApp adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {

        adaptee.jMenuItem1_actionPerformed(e);
    }
}


class zsStudentApp_jMenuItem3_actionAdapter implements ActionListener {
    private zsStudentApp adaptee;
    zsStudentApp_jMenuItem3_actionAdapter(zsStudentApp adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {

        adaptee.jMenuItem3_actionPerformed(e);
    }
}


class zsStudentApp_jMenuBar1_ancestorAdapter implements AncestorListener {
    private zsStudentApp adaptee;
    zsStudentApp_jMenuBar1_ancestorAdapter(zsStudentApp adaptee) {
        this.adaptee = adaptee;
    }

    public void ancestorAdded(AncestorEvent event) {
        adaptee.jMenuBar1_ancestorAdded(event);
    }

    public void ancestorRemoved(AncestorEvent event) {
    }

    public void ancestorMoved(AncestorEvent event) {
    }
}


class zsStudentApp_contentPane_ancestorAdapter implements AncestorListener {
    private zsStudentApp adaptee;
    zsStudentApp_contentPane_ancestorAdapter(zsStudentApp adaptee) {
        this.adaptee = adaptee;
    }

    public void ancestorAdded(AncestorEvent event) {
        adaptee.contentPane_ancestorAdded(event);
    }

    public void ancestorRemoved(AncestorEvent event) {
    }

    public void ancestorMoved(AncestorEvent event) {
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -