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

📄 mainframe.java

📁 用java写的学生成绩管理系统。课程设计
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) ansi 
// Source File Name:   MainFrame.java

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.PrintStream;
import java.sql.*;
import java.util.Vector;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.AbstractTableModel;

public class MainFrame extends JFrame
    implements ActionListener, ListSelectionListener
{

    

    JFrame myWindow;
    private JMenuBar menuBar;
    private static Connection conn;
    private static Statement comm;
    private static ResultSet rs;
    private JRadioButtonMenuItem courseMath;
    private JRadioButtonMenuItem courseC;
    private JRadioButtonMenuItem courseJava;
    private JRadioButtonMenuItem courseDatastr;
    private JRadioButtonMenuItem courseDatabank;
    private JRadioButtonMenuItem courseSystem;
    private JMenuItem Record;
    private JMenuItem Find;
    private JMenuItem Redel;
    private JMenuItem Refurbish;
    private JMenuItem Stuids;
    private JMenuItem Stuidz;
    private JMenuItem Scores;
    private JMenuItem Scorez;
    private JMenuItem Password;
    private JMenuItem Outlogin;
    private JMenuItem Aboutme;
    private JPanel cardRecord;
    private JPanel cardFind;
    private JPanel cardRedel;
    private JPanel carddl;
    private JPanel cardwc;
    private static JLabel jl;
    private static JLabel jl2;
    private static JLabel jl3;
    private Font t;
    private static String scourse = "Math";
    String data2[] = {
        "stuid=", "stuid>", "stuid<", "name=", "score=", "score>=", "score<"
    };
    JComboBox data2List;
    static JButton go;
    static JButton add2;
    static JButton drop;
    static JButton del;
    static JButton jbse;
    static JButton flush;
    static JButton dl;
    static JButton ss;
    JTable jt;
    private static JTextField jid;
    private static JTextField jname;
    private static JTextField jscore;
    private static JTextField se;
    private static JTextField uname;
    private static JTextField upassword;
    private static JTextField jid2;
    private static JTextField jname2;
    private static JTextField jscore2;
    private static int total = 0;
    private static int k = 10;
    private static int row = 0;
    private static int i = 0;
    JScrollPane s;
    Vector vect;
    String columnNames[] = {
        "学号(stuid)", "姓名(name)", "分数(score)"
    };
    AbstractTableModel tm;
    private static String sql;


    public MainFrame()
    {
        menuBar = new JMenuBar();
        courseMath = new JRadioButtonMenuItem("高等数学", true);
        courseC = new JRadioButtonMenuItem("C语言", false);
        courseJava = new JRadioButtonMenuItem("Java程序设计", false);
        courseDatastr = new JRadioButtonMenuItem("数据结构", false);
        courseDatabank = new JRadioButtonMenuItem("数据库", false);
        courseSystem = new JRadioButtonMenuItem("操作系统", false);
        Record = new JMenuItem("录入");
        Find = new JMenuItem("查询");
        Redel = new JMenuItem("修改或删除");
        Refurbish = new JMenuItem("刷新");
        Stuids = new JMenuItem("学号(小->大)");
        Stuidz = new JMenuItem("学号(大->小)");
        Scores = new JMenuItem("成绩(低->高)");
        Scorez = new JMenuItem("成绩(高->低)");
        Password = new JMenuItem("修改登录密码");
        Outlogin = new JMenuItem("退出系统");
        Aboutme = new JMenuItem("关于本程序");
        cardRecord = new JPanel();
        cardFind = new JPanel();
        cardRedel = new JPanel();
        carddl = new JPanel();
        cardwc = new JPanel();
        t = new Font("宋体", 0, 12);
        data2List = new JComboBox(data2);
        vect = new Vector();
        tm = new AbstractTableModel() {

            public int getColumnCount()
            {
                return 3;
            }

            public int getRowCount()
            {
                return MainFrame.k;
            }

            public Object getValueAt(int j, int l)
            {
                return ((Vector)vect.get(j)).get(l);
            }

            public String getColumnName(int j)
            {
                return columnNames[j];
            }

            final MainFrame this$0;

            
            {
                this$0 = MainFrame.this;
                super();
            }
        }
;
        myWindow = new JFrame("The SecondTeam of class 10 学生成绩管理系统");
        setDefaultCloseOperation(3);
        myWindow.setResizable(false);
        setcardRecordPanel();
        setcardFindPanel();
        setcardRedelPanel();
        setdlPanel();
        setwcPanel();
        FlowLayout flowlayout = new FlowLayout();
        myWindow.getContentPane().setLayout(flowlayout);
        myWindow.setJMenuBar(menuBar);
        JMenu jmenu = new JMenu("选择课程");
        JMenu jmenu1 = new JMenu("操作");
        JMenu jmenu2 = new JMenu("系统管理");
        JMenu jmenu3 = new JMenu("排序");
        jl2 = new JLabel("");
        jmenu.add(courseMath);
        jmenu.add(courseC);
        jmenu.add(courseJava);
        jmenu.add(courseDatastr);
        jmenu.add(courseDatabank);
        jmenu.add(courseSystem);
        ButtonGroup buttongroup = new ButtonGroup();
        buttongroup.add(courseMath);
        buttongroup.add(courseC);
        buttongroup.add(courseJava);
        buttongroup.add(courseDatastr);
        buttongroup.add(courseDatabank);
        buttongroup.add(courseSystem);
        jmenu1.add(Record);
        jmenu1.add(Find);
        jmenu1.add(Redel);
        jmenu1.addSeparator();
        jmenu1.add(Refurbish);
        jmenu3.add(Stuids);
        jmenu3.add(Stuidz);
        jmenu3.add(Scorez);
        jmenu3.add(Scores);
        jmenu2.add(Aboutme);
        jmenu2.add(Password);
        jmenu2.addSeparator();
        jmenu2.add(Outlogin);
        menuBar.add(jmenu);
        menuBar.add(jmenu1);
        menuBar.add(jmenu3);
        menuBar.add(jmenu2);
        courseMath.addActionListener(this);
        courseC.addActionListener(this);
        courseJava.addActionListener(this);
        courseDatastr.addActionListener(this);
        courseDatabank.addActionListener(this);
        courseSystem.addActionListener(this);
        Record.addActionListener(this);
        Find.addActionListener(this);
        Redel.addActionListener(this);
        Refurbish.addActionListener(this);
        Stuids.addActionListener(this);
        Stuidz.addActionListener(this);
        Scores.addActionListener(this);
        Scorez.addActionListener(this);
        Password.addActionListener(this);
        Outlogin.addActionListener(this);
        Aboutme.addActionListener(this);
        del.addActionListener(this);
        add2.addActionListener(this);
        drop.addActionListener(this);
        jbse.addActionListener(this);
        ss.addActionListener(this);
        dl.addActionListener(this);
        jmenu.setFont(t);
        jmenu1.setFont(t);
        jmenu2.setFont(t);
        jmenu3.setFont(t);
        courseMath.setFont(t);
        courseC.setFont(t);
        courseJava.setFont(t);
        courseDatastr.setFont(t);
        courseDatabank.setFont(t);
        courseSystem.setFont(t);
        Record.setFont(t);
        Find.setFont(t);
        Redel.setFont(t);
        Refurbish.setFont(t);
        Stuids.setFont(t);
        Stuidz.setFont(t);
        Scores.setFont(t);
        Scorez.setFont(t);
        Password.setFont(t);
        Outlogin.setFont(t);
        Aboutme.setFont(t);
        myWindow.getContentPane().add(cardRecord);
        myWindow.getContentPane().add(cardRedel);
        myWindow.getContentPane().add(cardFind);
        myWindow.getContentPane().add(carddl);
        myWindow.getContentPane().add(cardwc);
        hidecard();
        jt = new JTable(tm);
        jt.setSelectionMode(0);
        jt.getSelectionModel().addListSelectionListener(this);
        s = new JScrollPane(jt);
        myWindow.getContentPane().add(s);
        myWindow.getContentPane().add(jl2);
        s.setVisible(false);
        carddl.setVisible(true);
        cardwc.setVisible(false);
    }

    public void setwcPanel()
    {
        FlowLayout flowlayout = new FlowLayout();
        cardwc.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), ""));
        cardwc.setLayout(flowlayout);
        jl3 = new JLabel("10班第二小组《学生成绩管理系统》,正在管理的课程是:高等数学");
        cardwc.add(jl3);
    }

    public void setcardRecordPanel()
    {
        FlowLayout flowlayout = new FlowLayout();
        cardRecord.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "录入"));
        cardRecord.setLayout(flowlayout);
        add2 = new JButton("添加");
        jid2 = new JTextField(8);
        jname2 = new JTextField(7);
        jscore2 = new JTextField(5);
        cardRecord.add(new JLabel("学号:"));
        cardRecord.add(jid2);
        cardRecord.add(new JLabel("姓名:"));
        cardRecord.add(jname2);
        cardRecord.add(new JLabel("分数:"));
        cardRecord.add(jscore2);
        cardRecord.add(add2);
    }

    public void setcardFindPanel()
    {
        FlowLayout flowlayout = new FlowLayout();
        cardFind.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "查询"));
        cardFind.setLayout(flowlayout);
        se = new JTextField(9);
        jbse = new JButton("搜索");
        ss = new JButton("刷新");
        cardFind.add(new JLabel("搜索学生:"));
        cardFind.add(data2List);
        cardFind.add(se);
        cardFind.add(jbse);
        cardFind.add(ss);
    }

    public void setcardRedelPanel()
    {
        FlowLayout flowlayout = new FlowLayout();
        cardRedel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), ""));
        cardRedel.setLayout(flowlayout);
        jid = new JTextField(7);
        jname = new JTextField(7);
        jscore = new JTextField(5);
        drop = new JButton("修改");
        del = new JButton("删除");
        cardRedel.add(new JLabel("学号:"));
        cardRedel.add(jid);
        cardRedel.add(new JLabel("姓名:"));
        cardRedel.add(jname);
        cardRedel.add(new JLabel("分数:"));
        cardRedel.add(jscore);
        cardRedel.add(drop);
        cardRedel.add(del);
    }

    public void setdlPanel()
    {
        FlowLayout flowlayout = new FlowLayout();
        carddl.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "请输入登录帐号密码"));
        carddl.setLayout(flowlayout);
        uname = new JTextField(7);
        upassword = new JTextField(7);
        dl = new JButton("登录");
        carddl.add(uname);
        carddl.add(upassword);
        carddl.add(dl);
    }

    public void hidecard()
    {
        cardwc.setVisible(false);
        cardRecord.setVisible(false);
        cardRedel.setVisible(false);
        cardFind.setVisible(false);
        carddl.setVisible(false);
    }

    public void exce(String s1)
    {
        try
        {
            jt.getSelectionModel().removeListSelectionListener(this);
            rs = execQuery(s1);
            vect.removeAllElements();
            tm.fireTableDataChanged();
            for(total = 0; rs.next(); total++)
            {
                Vector vector = new Vector();
                vector.addElement(rs.getString(1));
                vector.addElement(rs.getString(2));
                vector.addElement(rs.getString(3));
                vect.addElement(vector);
            }

            k = total;
            MainFrame _tmp = this;
            closeDB();
            System.out.println((new StringBuilder()).append("成功执行:").append(s1).toString());
            jt.getSelectionModel().addListSelectionListener(this);
        }
        catch(Exception exception)
        {
            jl2.setText("无法执行,请填入正确的数据");
            System.out.println("执行失败,可能查询为空");
            k = 0;
        }
    }

⌨️ 快捷键说明

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