Java信息管理系统界面设计(包括登录界面及界面切换)

课程设计 专栏收录该内容
0 篇文章 0 订阅

Java学生成绩管理系统界面设计(包括登录界面及界面切换),内含学生成绩管理系统各用户应有功能模块设计。

登录界面

package Panel;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

/*

  • 登录界面
    */
    public class Login{
    JFrame frame;
    ImageIcon logo;
    JLabel jl1,jl2,jl3;
    JTextField name;
    JPasswordField password;
    JRadioButton stu,tea,adm;
    ButtonGroup group;
    JButton b1;
    public Login() {
    frame=new JFrame(“学生成绩管理系统”);
    frame.setLayout(new FlowLayout());

     //登录界面布局
     logo=new ImageIcon("C:/Users/雷晨宇/eclipse-workspace/Student_Grade/logo.png");
     jl1=new JLabel(logo);
     frame.add(jl1);
     
     jl2=new JLabel("账号");
     jl2.setPreferredSize(new Dimension(150,30));
     frame.add(jl2);
     
     name=new JTextField();
     name.setPreferredSize(new Dimension(250, 30));
     frame.add(name);
     
     jl3=new JLabel("密码");
     jl3.setPreferredSize(new Dimension(150,30));
     frame.add(jl3);
     
     password=new JPasswordField();
     password.setPreferredSize(new Dimension(250, 30));
     frame.add(password);
     
     JLabel null1=new JLabel();
     null1.setPreferredSize(new Dimension(140,30));
     frame.add(null1);
     
     //学生,教师,管理员单选框设置
     group=new ButtonGroup();
     stu=new JRadioButton("学生");
     tea=new JRadioButton("教师");
     adm=new JRadioButton("管理员");
     frame.add(stu);group.add(stu);
     frame.add(tea);group.add(tea);
     frame.add(adm);group.add(adm);
     
     JLabel null2=new JLabel();
     null2.setPreferredSize(new Dimension(140,30));
     frame.add(null2);
     
     b1=new JButton("登录");
     frame.add(b1);
     
     //登录时选择登陆用户:学生,教师,管理员
     b1.addActionListener(new ActionListener() {
     	public void actionPerformed(ActionEvent e) {
     		if(stu.isSelected()) {
     			if(name.getText().equals("1")&&new String(password.getPassword()).equals("1")) {
     				JOptionPane.showMessageDialog(null,"登录成功");
     				new StudentPanel(name.getText());
     				frame.dispose();
     			}else {
     				JOptionPane.showMessageDialog(null, "登录失败");
     				name.setText("");password.setText("");
     			}
     		}else if(tea.isSelected()) {
     			if(name.getText().trim().equals("1")&&new String(password.getPassword()).equals("1")) {
     				JOptionPane.showMessageDialog(null,"登录成功");
     				new TeacherPanel(name.getText());
     				frame.dispose();
     			}else {
     				JOptionPane.showMessageDialog(null, "登录失败");
     				name.setText("");password.setText("");
     			}
     		}else if(adm.isSelected()) {
     			if(name.getText().trim().equals("1")&&new String(password.getPassword()).equals("1")) {
     				JOptionPane.showMessageDialog(null,"登录成功");
     				new AdmPanel();
     				frame.dispose();
     			}else {
     				JOptionPane.showMessageDialog(null, "登录失败");
     				name.setText("");password.setText("");
     			}
     		}
     		
     	}
     		
     });
    
     frame.setSize(540,300);
     frame.setVisible(true);
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    

    }

}

学生用户界面

package Panel;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;

/*

  • 学生用户界面
    */
    public class StudentPanel {
    JFrame frame;
    JLabel l1,l2,l3,l4,l5,l6;
    JTextField tf1,tf2,tf3,tf4,tf5,tf6;
    JButton b1,b2,b3,b4,b5;
    public StudentPanel(String stuid){
    frame=new JFrame(“学生成绩管理系统”);
    frame.setLayout(new BorderLayout());

     //学生用户界面布局
     tf1=new JTextField();tf1.setText("欢迎"+stuid+"同学进入学生成绩管理系统");
     tf1.setBackground(Color.CYAN);tf1.setEditable(false);
     JPanel p1=new JPanel(new FlowLayout(FlowLayout.RIGHT));
     p1.add(tf1);
     
     b1=new JButton("显示个人信息");
     b2=new JButton("查询单科成绩");
     b3=new JButton("查询全部成绩");
     b4=new JButton("修改密码");
     b5=new JButton("退出");
     JPanel p2=new JPanel(new FlowLayout());
     p2.add(b1);p2.add(b2);p2.add(b3);
     p2.add(b4);p2.add(b5);
     JPanel p=new JPanel(new GridLayout(2,1));
     p.add(p1);p.add(p2);
     frame.add(p,BorderLayout.NORTH);
     
     
     //显示,修改学生基本信息
     b1.addActionListener(new ActionListener() {
     	public void actionPerformed(ActionEvent e) {
     		p2.setVisible(false);
     		
     		//设置标签,文本框,按钮布局
     		l1=new JLabel("学号");tf1=new JTextField();	
     		l2=new JLabel("姓名");tf2=new JTextField();		
     		l3=new JLabel("性别");tf3=new JTextField();		
     		l4=new JLabel("出生日期");tf4=new JTextField();		
     		l5=new JLabel("专业");tf5=new JTextField();
     		l6=new JLabel("班级");tf6=new JTextField();
     		
     		l1.setPreferredSize(new Dimension(150,30));
     		tf1.setPreferredSize(new Dimension(250,30));
     		l2.setPreferredSize(new Dimension(150,30));
     		tf2.setPreferredSize(new Dimension(250,30));
     		l3.setPreferredSize(new Dimension(150,30));
     		tf3.setPreferredSize(new Dimension(250,30));
     		l4.setPreferredSize(new Dimension(150,30));
     		tf4.setPreferredSize(new Dimension(250,30));
     		l5.setPreferredSize(new Dimension(150,30));
     		tf5.setPreferredSize(new Dimension(250,30));
     		l6.setPreferredSize(new Dimension(150,30));
     		tf6.setPreferredSize(new Dimension(250,30));
     		
     		//学生不可修改学号,专业,班级,文本框设置不可编辑
     		tf1.setBackground(Color.LIGHT_GRAY);tf1.setEditable(false);
     		tf5.setBackground(Color.LIGHT_GRAY);tf5.setEditable(false);
     		tf6.setBackground(Color.LIGHT_GRAY);tf6.setEditable(false);
     		
     		b1=new JButton("保存");b2=new JButton("退出");
     		
     		JPanel ShowStudent=new JPanel();
     		ShowStudent.setLayout(new FlowLayout());
     		
     		ShowStudent.add(l1);ShowStudent.add(tf1);
     		ShowStudent.add(l2);ShowStudent.add(tf2);
     		ShowStudent.add(l3);ShowStudent.add(tf3);
     		ShowStudent.add(l4);ShowStudent.add(tf4);
     		ShowStudent.add(l5);ShowStudent.add(tf5);
     		ShowStudent.add(l6);ShowStudent.add(tf6);
    
     		JLabel null1=new JLabel();
     		null1.setPreferredSize(new Dimension(140,30));
     		ShowStudent.add(null1);
     		
     		ShowStudent.add(b1);ShowStudent.add(b2);
     		frame.add(ShowStudent,BorderLayout.CENTER);
     		
     		//保存修改信息
     		b1.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				JOptionPane.showMessageDialog(null,"成功保存");
     			}
     		});
     		
     		//返回学生用户主界面
     		b2.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				ShowStudent.setVisible(false);
     				p1.setVisible(true);p2.setVisible(true);
     			}
     		});
     	}
     });
    
     //查询单科成绩,输入课程名,显示成绩
     b2.addActionListener(new ActionListener() {
     	public void actionPerformed(ActionEvent e) {
     		p2.setVisible(false);
     		
     		//设置标签,文本框,按钮布局
     		l1=new JLabel("课程名");tf1=new JTextField();
     		l2=new JLabel("成绩");tf2=new JTextField();
     		
     		l1.setPreferredSize(new Dimension(150,30));
     		tf1.setPreferredSize(new Dimension(250,30));
     		l2.setPreferredSize(new Dimension(150,30));
     		tf2.setPreferredSize(new Dimension(250,30));
     		
     		b1=new JButton("查询");b2=new JButton("退出");
     		
     		JPanel ShowStudent=new JPanel();
     		ShowStudent.setLayout(new FlowLayout());
     		
     		ShowStudent.add(l1);ShowStudent.add(tf1);
     		ShowStudent.add(l2);ShowStudent.add(tf2);
    
     		JLabel null1=new JLabel();
     		null1.setPreferredSize(new Dimension(140,30));
     		ShowStudent.add(null1);
     		
     		ShowStudent.add(b1);ShowStudent.add(b2);
     		frame.add(ShowStudent,BorderLayout.CENTER);
     		
     		//查询单科成绩
     		b1.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				if(tf1.getText().equals("")) {
     					JOptionPane.showMessageDialog(null,"输入课程不存在,请重新输入");
     				}
     			}
     		});
     		
     		//返回学生用户界面
     		b2.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				ShowStudent.setVisible(false);
     				p1.setVisible(true);p2.setVisible(true);
     			}
     		});
     	}
     });
     
     //查询成绩单,显示所有成绩
     b3.addActionListener(new ActionListener() {
     	public void actionPerformed(ActionEvent e) {
     		p2.setVisible(false);
     		
     		//添加滑动窗口
     		JScrollPane jscrollpane=new JScrollPane();
     		
     		//添加表格
     		Object[] columnNames=new Object[]{"课程号","课程名","成绩"};//列名
     		Object[][] rowData=new Object[100][3];//行数,列数
     		JTable table=new JTable(rowData,columnNames);
     		jscrollpane.setViewportView(table);
     		table.setRowHeight(25);
     		DefaultTableCellRenderer r = new DefaultTableCellRenderer();    
     		r.setHorizontalAlignment(JLabel.CENTER);   
     		table.setDefaultRenderer(Object.class,r);
     		
     		b1=new JButton("退出");
     		
     		JPanel ShowStudent=new JPanel();
     		ShowStudent.setLayout(new FlowLayout());
     		
     		ShowStudent.add(jscrollpane);
     		ShowStudent.add(b1);
     		frame.add(ShowStudent,BorderLayout.CENTER);
     		
     		//返回学生用户界面
     		b1.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				ShowStudent.setVisible(false);
     				p1.setVisible(true);p2.setVisible(true);
     			}
     		});
     	}
     });
    
     //修改密码
     b4.addActionListener(new ActionListener() {
     	public void actionPerformed(ActionEvent e) {
     		p2.setVisible(false);
     		
     		//设置标签,文本框,按钮布局
     		l1=new JLabel("请输入原密码");tf1=new JTextField();
     		l2=new JLabel("请输入新密码");JPasswordField tf2=new JPasswordField();
     		l3=new JLabel("请再次输入新密码");JPasswordField tf3=new JPasswordField();
     		
     		l1.setPreferredSize(new Dimension(150,30));
     		tf1.setPreferredSize(new Dimension(250,30));
     		l2.setPreferredSize(new Dimension(150,30));
     		tf2.setPreferredSize(new Dimension(250,30));
     		l3.setPreferredSize(new Dimension(150,30));
     		tf3.setPreferredSize(new Dimension(250,30));
     		
     		b1=new JButton("确定");b2=new JButton("退出");
     		
     		JPanel ShowStudent=new JPanel();
     		ShowStudent.setLayout(new FlowLayout());
     		
     		ShowStudent.add(l1);ShowStudent.add(tf1);
     		ShowStudent.add(l2);ShowStudent.add(tf2);
     		ShowStudent.add(l3);ShowStudent.add(tf3);
    
     		JLabel null1=new JLabel();
     		null1.setPreferredSize(new Dimension(140,30));
     		ShowStudent.add(null1);
     		
     		ShowStudent.add(b1);ShowStudent.add(b2);
     		frame.add(ShowStudent,BorderLayout.CENTER);
     		
     		//确定修改
     		b1.addActionListener(new ActionListener() {
     			@SuppressWarnings("deprecation")
     			public void actionPerformed(ActionEvent e) {
     				//输入均为空提示
     				if(tf1.getText().equals("") || tf2.getText().equals("") || tf3.getText().equals("")) {
     					JOptionPane.showMessageDialog(null,"输入信息不完整,请重新输入");
     				}
     				//新密码验证一致,修改成功
     				else if(tf2.getText().equals(tf3.getText())) {
     					JOptionPane.showMessageDialog(null,"密码修改成功");
     					tf1.setText("");tf2.setText("");tf3.setText("");
     				}
     				//新密码验证不一致,修改失败
     				else {
     					JOptionPane.showMessageDialog(null,"两次输入不一致,请重新输入");
     					tf2.setText("");tf3.setText("");
     				}
     			}
     		});
     		
     		//返回学生用户界面
     		b2.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				ShowStudent.setVisible(false);
     				p1.setVisible(true);p2.setVisible(true);
     			}
     		});
     	}
     });
     
     //退出,返回登录界面
     b5.addActionListener(new ActionListener() {
     	public void actionPerformed(ActionEvent e) {
     		new Login();
     		frame.setVisible(false);
     	}
     });
     frame.setSize(540,650);
     frame.setVisible(true);
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    

    }

}

教师用户界面

package Panel;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;

/*

  • 学生用户界面
    */
    public class StudentPanel {
    JFrame frame;
    JLabel l1,l2,l3,l4,l5,l6;
    JTextField tf1,tf2,tf3,tf4,tf5,tf6;
    JButton b1,b2,b3,b4,b5;
    public StudentPanel(String stuid){
    frame=new JFrame(“学生成绩管理系统”);
    frame.setLayout(new BorderLayout());

     //学生用户界面布局
     tf1=new JTextField();tf1.setText("欢迎"+stuid+"同学进入学生成绩管理系统");
     tf1.setBackground(Color.CYAN);tf1.setEditable(false);
     JPanel p1=new JPanel(new FlowLayout(FlowLayout.RIGHT));
     p1.add(tf1);
     
     b1=new JButton("显示个人信息");
     b2=new JButton("查询单科成绩");
     b3=new JButton("查询全部成绩");
     b4=new JButton("修改密码");
     b5=new JButton("退出");
     JPanel p2=new JPanel(new FlowLayout());
     p2.add(b1);p2.add(b2);p2.add(b3);
     p2.add(b4);p2.add(b5);
     JPanel p=new JPanel(new GridLayout(2,1));
     p.add(p1);p.add(p2);
     frame.add(p,BorderLayout.NORTH);
     
     
     //显示,修改学生基本信息
     b1.addActionListener(new ActionListener() {
     	public void actionPerformed(ActionEvent e) {
     		p2.setVisible(false);
     		
     		//设置标签,文本框,按钮布局
     		l1=new JLabel("学号");tf1=new JTextField();	
     		l2=new JLabel("姓名");tf2=new JTextField();		
     		l3=new JLabel("性别");tf3=new JTextField();		
     		l4=new JLabel("出生日期");tf4=new JTextField();		
     		l5=new JLabel("专业");tf5=new JTextField();
     		l6=new JLabel("班级");tf6=new JTextField();
     		
     		l1.setPreferredSize(new Dimension(150,30));
     		tf1.setPreferredSize(new Dimension(250,30));
     		l2.setPreferredSize(new Dimension(150,30));
     		tf2.setPreferredSize(new Dimension(250,30));
     		l3.setPreferredSize(new Dimension(150,30));
     		tf3.setPreferredSize(new Dimension(250,30));
     		l4.setPreferredSize(new Dimension(150,30));
     		tf4.setPreferredSize(new Dimension(250,30));
     		l5.setPreferredSize(new Dimension(150,30));
     		tf5.setPreferredSize(new Dimension(250,30));
     		l6.setPreferredSize(new Dimension(150,30));
     		tf6.setPreferredSize(new Dimension(250,30));
     		
     		//学生不可修改学号,专业,班级,文本框设置不可编辑
     		tf1.setBackground(Color.LIGHT_GRAY);tf1.setEditable(false);
     		tf5.setBackground(Color.LIGHT_GRAY);tf5.setEditable(false);
     		tf6.setBackground(Color.LIGHT_GRAY);tf6.setEditable(false);
     		
     		b1=new JButton("保存");b2=new JButton("退出");
     		
     		JPanel ShowStudent=new JPanel();
     		ShowStudent.setLayout(new FlowLayout());
     		
     		ShowStudent.add(l1);ShowStudent.add(tf1);
     		ShowStudent.add(l2);ShowStudent.add(tf2);
     		ShowStudent.add(l3);ShowStudent.add(tf3);
     		ShowStudent.add(l4);ShowStudent.add(tf4);
     		ShowStudent.add(l5);ShowStudent.add(tf5);
     		ShowStudent.add(l6);ShowStudent.add(tf6);
    
     		JLabel null1=new JLabel();
     		null1.setPreferredSize(new Dimension(140,30));
     		ShowStudent.add(null1);
     		
     		ShowStudent.add(b1);ShowStudent.add(b2);
     		frame.add(ShowStudent,BorderLayout.CENTER);
     		
     		//保存修改信息
     		b1.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				JOptionPane.showMessageDialog(null,"成功保存");
     			}
     		});
     		
     		//返回学生用户主界面
     		b2.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				ShowStudent.setVisible(false);
     				p1.setVisible(true);p2.setVisible(true);
     			}
     		});
     	}
     });
    
     //查询单科成绩,输入课程名,显示成绩
     b2.addActionListener(new ActionListener() {
     	public void actionPerformed(ActionEvent e) {
     		p2.setVisible(false);
     		
     		//设置标签,文本框,按钮布局
     		l1=new JLabel("课程名");tf1=new JTextField();
     		l2=new JLabel("成绩");tf2=new JTextField();
     		
     		l1.setPreferredSize(new Dimension(150,30));
     		tf1.setPreferredSize(new Dimension(250,30));
     		l2.setPreferredSize(new Dimension(150,30));
     		tf2.setPreferredSize(new Dimension(250,30));
     		
     		b1=new JButton("查询");b2=new JButton("退出");
     		
     		JPanel ShowStudent=new JPanel();
     		ShowStudent.setLayout(new FlowLayout());
     		
     		ShowStudent.add(l1);ShowStudent.add(tf1);
     		ShowStudent.add(l2);ShowStudent.add(tf2);
    
     		JLabel null1=new JLabel();
     		null1.setPreferredSize(new Dimension(140,30));
     		ShowStudent.add(null1);
     		
     		ShowStudent.add(b1);ShowStudent.add(b2);
     		frame.add(ShowStudent,BorderLayout.CENTER);
     		
     		//查询单科成绩
     		b1.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				if(tf1.getText().equals("")) {
     					JOptionPane.showMessageDialog(null,"输入课程不存在,请重新输入");
     				}
     			}
     		});
     		
     		//返回学生用户界面
     		b2.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				ShowStudent.setVisible(false);
     				p1.setVisible(true);p2.setVisible(true);
     			}
     		});
     	}
     });
     
     //查询成绩单,显示所有成绩
     b3.addActionListener(new ActionListener() {
     	public void actionPerformed(ActionEvent e) {
     		p2.setVisible(false);
     		
     		//添加滑动窗口
     		JScrollPane jscrollpane=new JScrollPane();
     		
     		//添加表格
     		Object[] columnNames=new Object[]{"课程号","课程名","成绩"};//列名
     		Object[][] rowData=new Object[100][3];//行数,列数
     		JTable table=new JTable(rowData,columnNames);
     		jscrollpane.setViewportView(table);
     		table.setRowHeight(25);
     		DefaultTableCellRenderer r = new DefaultTableCellRenderer();    
     		r.setHorizontalAlignment(JLabel.CENTER);   
     		table.setDefaultRenderer(Object.class,r);
     		
     		b1=new JButton("退出");
     		
     		JPanel ShowStudent=new JPanel();
     		ShowStudent.setLayout(new FlowLayout());
     		
     		ShowStudent.add(jscrollpane);
     		ShowStudent.add(b1);
     		frame.add(ShowStudent,BorderLayout.CENTER);
     		
     		//返回学生用户界面
     		b1.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				ShowStudent.setVisible(false);
     				p1.setVisible(true);p2.setVisible(true);
     			}
     		});
     	}
     });
    
     //修改密码
     b4.addActionListener(new ActionListener() {
     	public void actionPerformed(ActionEvent e) {
     		p2.setVisible(false);
     		
     		//设置标签,文本框,按钮布局
     		l1=new JLabel("请输入原密码");tf1=new JTextField();
     		l2=new JLabel("请输入新密码");JPasswordField tf2=new JPasswordField();
     		l3=new JLabel("请再次输入新密码");JPasswordField tf3=new JPasswordField();
     		
     		l1.setPreferredSize(new Dimension(150,30));
     		tf1.setPreferredSize(new Dimension(250,30));
     		l2.setPreferredSize(new Dimension(150,30));
     		tf2.setPreferredSize(new Dimension(250,30));
     		l3.setPreferredSize(new Dimension(150,30));
     		tf3.setPreferredSize(new Dimension(250,30));
     		
     		b1=new JButton("确定");b2=new JButton("退出");
     		
     		JPanel ShowStudent=new JPanel();
     		ShowStudent.setLayout(new FlowLayout());
     		
     		ShowStudent.add(l1);ShowStudent.add(tf1);
     		ShowStudent.add(l2);ShowStudent.add(tf2);
     		ShowStudent.add(l3);ShowStudent.add(tf3);
    
     		JLabel null1=new JLabel();
     		null1.setPreferredSize(new Dimension(140,30));
     		ShowStudent.add(null1);
     		
     		ShowStudent.add(b1);ShowStudent.add(b2);
     		frame.add(ShowStudent,BorderLayout.CENTER);
     		
     		//确定修改
     		b1.addActionListener(new ActionListener() {
     			@SuppressWarnings("deprecation")
     			public void actionPerformed(ActionEvent e) {
     				//输入均为空提示
     				if(tf1.getText().equals("") || tf2.getText().equals("") || tf3.getText().equals("")) {
     					JOptionPane.showMessageDialog(null,"输入信息不完整,请重新输入");
     				}
     				//新密码验证一致,修改成功
     				else if(tf2.getText().equals(tf3.getText())) {
     					JOptionPane.showMessageDialog(null,"密码修改成功");
     					tf1.setText("");tf2.setText("");tf3.setText("");
     				}
     				//新密码验证不一致,修改失败
     				else {
     					JOptionPane.showMessageDialog(null,"两次输入不一致,请重新输入");
     					tf2.setText("");tf3.setText("");
     				}
     			}
     		});
     		
     		//返回学生用户界面
     		b2.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				ShowStudent.setVisible(false);
     				p1.setVisible(true);p2.setVisible(true);
     			}
     		});
     	}
     });
     
     //退出,返回登录界面
     b5.addActionListener(new ActionListener() {
     	public void actionPerformed(ActionEvent e) {
     		new Login();
     		frame.setVisible(false);
     	}
     });
     frame.setSize(540,650);
     frame.setVisible(true);
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    

    }

}

管理员用户界面

package Panel;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;

/*

  • 管理员用户界面
    */
    public class AdmPanel {
    JFrame frame;
    JPanel p1,p2,p3;
    JLabel l1,l2,l3,l4,l5,l6;
    JTextField tf1,tf2,tf3,tf4,tf5,tf6;
    JButton b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12;
    public AdmPanel(){
    frame=new JFrame(“学生成绩管理系统”);
    frame.setLayout(new BorderLayout());

     //管理员用户界面布局
     tf1=new JTextField();tf1.setText("欢迎进入学生成绩管理系统");
     tf1.setBackground(Color.CYAN);tf1.setEditable(false);
     p1=new JPanel(new FlowLayout(FlowLayout.RIGHT));
     p1.add(tf1);
     
     b1=new JButton("添加学生");b2=new JButton("添加教师");b3=new JButton("添加课程");
     b4=new JButton("查询学生");b5=new JButton("查询教师");b6=new JButton("查询课程");
     b7=new JButton("删除学生");b8=new JButton("删除教师");b9=new JButton("删除课程");
     b10=new JButton("查询成绩");b11=new JButton("成绩汇总");b12=new JButton("退出");
     p2=new JPanel(new GridLayout(2,6));
     p2.add(b1);p2.add(b2);p2.add(b3);
     p2.add(b4);p2.add(b5);p2.add(b6);
     p2.add(b7);p2.add(b8);p2.add(b9);
     p2.add(b10);p2.add(b11);p2.add(b12);
     JPanel p=new JPanel(new GridLayout(2,1));
     p.add(p1);p.add(p2);
     frame.add(p,BorderLayout.NORTH);
     
     //添加学生信息
     b1.addActionListener(new ActionListener() {
     	public void actionPerformed(ActionEvent e) {
     		p2.setVisible(false);
     		
     		p3=new JPanel(new FlowLayout());
     		
     		//设置标签,文本框,按钮布局
     		l1=new JLabel("专业");l1.setPreferredSize(new Dimension(200,30));
     		tf1=new JTextField();tf1.setPreferredSize(new Dimension(300,30));
     		p3.add(l1);p3.add(tf1);
     		
     		l2=new JLabel("班级");l2.setPreferredSize(new Dimension(200,30));
     		tf2=new JTextField();tf2.setPreferredSize(new Dimension(300,30));
     		p3.add(l2);p3.add(tf2);
     		
     		l3=new JLabel("学号");l3.setPreferredSize(new Dimension(200,30));
     		tf3=new JTextField();tf3.setPreferredSize(new Dimension(300,30));
     		p3.add(l3);p3.add(tf3);
     		
     		l4=new JLabel("姓名");l4.setPreferredSize(new Dimension(200,30));
     		tf4=new JTextField();tf4.setPreferredSize(new Dimension(300,30));
     		p3.add(l4);p3.add(tf4);
     		
     		l5=new JLabel("性别");l5.setPreferredSize(new Dimension(200,30));
     		tf5=new JTextField();tf5.setPreferredSize(new Dimension(300,30));
     		p3.add(l5);p3.add(tf5);
     		
     		l6=new JLabel("出生日期");l6.setPreferredSize(new Dimension(200,30));
     		tf6=new JTextField();tf6.setPreferredSize(new Dimension(300,30));
     		p3.add(l6);p3.add(tf6);
     		
     		JLabel null1=new JLabel();
     		null1.setPreferredSize(new Dimension(50,30));
     		p3.add(null1);
     		
     		b1=new JButton("添加");b2=new JButton("退出");
     		p3.add(b1);p3.add(b2);
     		frame.add(p3,BorderLayout.CENTER);
     		
     		//确定添加
     		b1.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				JOptionPane.showMessageDialog(null,"添加成功");
     				}
     		});
     		
     		//返回管理员用户界面
     		b2.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				p3.setVisible(false);
     				p1.setVisible(true);p2.setVisible(true);
     			}
     		});
     		
     	}
     });
     
     //添加教师信息
     b2.addActionListener(new ActionListener() {
     	public void actionPerformed(ActionEvent e) {
     		p2.setVisible(false);
     		
     		p3=new JPanel(new FlowLayout());
     		
     		//设置标签,文本框,按钮布局
     		l1=new JLabel("教师工号");l1.setPreferredSize(new Dimension(200,30));
     		tf1=new JTextField();tf1.setPreferredSize(new Dimension(300,30));
     		p3.add(l1);p3.add(tf1);
     		
     		l2=new JLabel("教师姓名");l2.setPreferredSize(new Dimension(200,30));
     		tf2=new JTextField();tf2.setPreferredSize(new Dimension(300,30));
     		p3.add(l2);p3.add(tf2);
     		
     		l3=new JLabel("性别");l3.setPreferredSize(new Dimension(200,30));
     		tf3=new JTextField();tf3.setPreferredSize(new Dimension(300,30));
     		p3.add(l3);p3.add(tf3);
     		
     		l4=new JLabel("出生日期");l4.setPreferredSize(new Dimension(200,30));
     		tf4=new JTextField();tf4.setPreferredSize(new Dimension(300,30));
     		p3.add(l4);p3.add(tf4);
     		
     		l5=new JLabel("所带课程");l5.setPreferredSize(new Dimension(200,30));
     		tf5=new JTextField();tf5.setPreferredSize(new Dimension(300,30));
     		p3.add(l5);p3.add(tf5);
     		
     		JLabel null1=new JLabel();
     		null1.setPreferredSize(new Dimension(50,30));
     		p3.add(null1);
     		
     		b1=new JButton("添加");b2=new JButton("退出");
     		p3.add(b1);p3.add(b2);
     		frame.add(p3,BorderLayout.CENTER);
     		
     		//确定添加
     		b1.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				JOptionPane.showMessageDialog(null,"添加成功");
     				}
     		});
     		
     		//返回管理员用户界面
     		b2.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				p3.setVisible(false);
     				p1.setVisible(true);p2.setVisible(true);
     			}
     		});
     		
     	}
     });
    
     //添加课程信息
     b3.addActionListener(new ActionListener() {
     	public void actionPerformed(ActionEvent e) {
     		p2.setVisible(false);
     		
     		p3=new JPanel(new FlowLayout());
     		
     		//设置标签,文本框,按钮布局
     		l1=new JLabel("课程号");l1.setPreferredSize(new Dimension(200,30));
     		tf1=new JTextField();tf1.setPreferredSize(new Dimension(300,30));
     		p3.add(l1);p3.add(tf1);
     		
     		l2=new JLabel("课程名");l2.setPreferredSize(new Dimension(200,30));
     		tf2=new JTextField();tf2.setPreferredSize(new Dimension(300,30));
     		p3.add(l2);p3.add(tf2);
     		
     		l3=new JLabel("授课教师");l3.setPreferredSize(new Dimension(200,30));
     		tf3=new JTextField();tf3.setPreferredSize(new Dimension(300,30));
     		p3.add(l3);p3.add(tf3);
     		
     		JLabel null1=new JLabel();
     		null1.setPreferredSize(new Dimension(50,30));
     		p3.add(null1);
     		
     		b1=new JButton("添加");b2=new JButton("退出");
     		p3.add(b1);p3.add(b2);
     		frame.add(p3,BorderLayout.CENTER);
     		
     		//确定添加
     		b1.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				JOptionPane.showMessageDialog(null,"添加成功");
     				}
     		});
     		
     		//返回管理员用户界面
     		b2.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				p3.setVisible(false);
     				p1.setVisible(true);p2.setVisible(true);
     			}
     		});
     		
     	}
     });
    
     //查询学生信息
     b4.addActionListener(new ActionListener() {
     	public void actionPerformed(ActionEvent e) {
     		p2.setVisible(false);
     		
     		p3=new JPanel(new FlowLayout());
     		
     		//设置标签,文本框,按钮布局
     		l1=new JLabel("专业");l1.setPreferredSize(new Dimension(200,30));
     		tf1=new JTextField();tf1.setPreferredSize(new Dimension(300,30));
     		p3.add(l1);p3.add(tf1);
     		
     		l2=new JLabel("班级");l2.setPreferredSize(new Dimension(200,30));
     		tf2=new JTextField();tf2.setPreferredSize(new Dimension(300,30));
     		p3.add(l2);p3.add(tf2);
     		
     		l3=new JLabel("学生学号");l3.setPreferredSize(new Dimension(200,30));
     		tf3=new JTextField();tf3.setPreferredSize(new Dimension(300,30));
     		p3.add(l3);p3.add(tf3);
     		
     		JScrollPane jscrollpane=new JScrollPane();
     		Object[] columnNames=new Object[]{"专业","班级","学号","姓名","性别","年龄"};//列名
     		Object[][] rowData=new Object[20000][6];//行数,列数
     		 JTable table=new JTable(rowData,columnNames);
     		jscrollpane.setViewportView(table);
     		table.setRowHeight(25);
     		DefaultTableCellRenderer r = new DefaultTableCellRenderer();    
     		r.setHorizontalAlignment(JLabel.CENTER);   
     		table.setDefaultRenderer(Object.class,r);
     		p3.add(jscrollpane);
     		
     		b1=new JButton("查询");b2=new JButton("退出");
     		p3.add(b1);p3.add(b2);
     		frame.add(p3,BorderLayout.CENTER);
     		
     		//根据输入查询学生信息
     		b1.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				
     			}
     		});
     		
     		//返回管理员用户界面
     		b2.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				p3.setVisible(false);
     				p1.setVisible(true);p2.setVisible(true);
     			}
     		});
     		
     	}
     });
    
     //查询教师信息
     b5.addActionListener(new ActionListener() {
     	public void actionPerformed(ActionEvent e) {
     		p2.setVisible(false);
     		
     		p3=new JPanel(new FlowLayout());
     		
     		//设置标签,文本框,按钮布局
     		l1=new JLabel("按教师工号查询");l1.setPreferredSize(new Dimension(200,30));
     		tf1=new JTextField();tf1.setPreferredSize(new Dimension(300,30));
     		p3.add(l1);p3.add(tf1);
     		
     		l2=new JLabel("按课程查询");l2.setPreferredSize(new Dimension(200,30));
     		tf2=new JTextField();tf2.setPreferredSize(new Dimension(300,30));
     		p3.add(l2);p3.add(tf2);
     		
     		JScrollPane jscrollpane=new JScrollPane();
     		
     		Object[] columnNames=new Object[]{"教师工号","姓名","所带课程"};//列名
     		Object[][] rowData=new Object[1000][3];//行数,列数
     		JTable table=new JTable(rowData,columnNames);
     		jscrollpane.setViewportView(table);
     		table.setRowHeight(25);
     		DefaultTableCellRenderer r = new DefaultTableCellRenderer();    
     		r.setHorizontalAlignment(JLabel.CENTER);   
     		table.setDefaultRenderer(Object.class,r);
     		p3.add(jscrollpane);
     		
     		b1=new JButton("查询");b2=new JButton("退出");
     		p3.add(b1);p3.add(b2);
     		frame.add(p3,BorderLayout.CENTER);
     		
     		//根据输入查询教师信息
     		b1.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				
     			}
     		});
     		
     		//返回管理员用户界面
     		b2.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				p3.setVisible(false);
     				p1.setVisible(true);p2.setVisible(true);
     			}
     		});
     		
     	}
     });
    
     //查询课程信息
     b6.addActionListener(new ActionListener() {
     	public void actionPerformed(ActionEvent e) {
     		p2.setVisible(false);
     		
     		p3=new JPanel(new FlowLayout());
     		
     		//设置标签,文本框,按钮布局
     		l1=new JLabel("课程号");l1.setPreferredSize(new Dimension(150,30));
     		tf1=new JTextField();tf1.setPreferredSize(new Dimension(250,30));
     		p3.add(l1);p3.add(tf1);
     		
     		l2=new JLabel("课程名");l2.setPreferredSize(new Dimension(150,30));
     		tf2=new JTextField();tf2.setPreferredSize(new Dimension(250,30));
     		p3.add(l2);p3.add(tf2);
     		
     		l3=new JLabel("专业");l3.setPreferredSize(new Dimension(150,30));
     		tf3=new JTextField();tf3.setPreferredSize(new Dimension(250,30));
     		p3.add(l3);p3.add(tf3);
    
     		l4=new JLabel("教师工号");l4.setPreferredSize(new Dimension(150,30));
     		tf4=new JTextField();tf4.setPreferredSize(new Dimension(250,30));
     		p3.add(l4);p3.add(tf4);
     		
     		JScrollPane jscrollpane=new JScrollPane();
     		
     		Object[] columnNames=new Object[]{"课程号","课程名","代课教师号","代课教师","上课专业"};//列名
     		Object[][] rowData=new Object[500][5];//行数,列数
     		 JTable table=new JTable(rowData,columnNames);
     		jscrollpane.setViewportView(table);
     		table.setRowHeight(25);
     		DefaultTableCellRenderer r = new DefaultTableCellRenderer();    
     		r.setHorizontalAlignment(JLabel.CENTER);   
     		table.setDefaultRenderer(Object.class,r);
     		p3.add(jscrollpane);
     		
     		b1=new JButton("查询");b2=new JButton("退出");
     		p3.add(b1);p3.add(b2);
     		frame.add(p3,BorderLayout.CENTER);
     		
     		//根据输入查询课程信息
     		b1.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				
     			}
     		});
     		
     		//返回管理员用户界面
     		b2.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				p3.setVisible(false);
     				p1.setVisible(true);p2.setVisible(true);
     			}
     		});
     		
     	}
     });
     
     //删除学生信息
     b7.addActionListener(new ActionListener() {
     	public void actionPerformed(ActionEvent e) {
     		p2.setVisible(false);
     		
     		p3=new JPanel(new FlowLayout());
     		
     		//设置标签,文本框,按钮布局
     		l1=new JLabel("学生学号");l1.setPreferredSize(new Dimension(200,30));
     		tf1=new JTextField();tf1.setPreferredSize(new Dimension(300,30));
     		p3.add(l1);p3.add(tf1);
     		
     		l2=new JLabel("学生姓名");l2.setPreferredSize(new Dimension(200,30));
     		tf2=new JTextField();tf2.setPreferredSize(new Dimension(300,30));
     		p3.add(l2);p3.add(tf2);
     		
     		l3=new JLabel("学生专业");l3.setPreferredSize(new Dimension(200,30));
     		tf3=new JTextField();tf3.setPreferredSize(new Dimension(300,30));
     		p3.add(l3);p3.add(tf3);
     		
     		l4=new JLabel("学生班级");l4.setPreferredSize(new Dimension(200,30));
     		tf4=new JTextField();tf4.setPreferredSize(new Dimension(300,30));
     		p3.add(l4);p3.add(tf4);
     		
     		JLabel null1=new JLabel();
     		null1.setPreferredSize(new Dimension(50,30));
     		p3.add(null1);
     		
     		b1=new JButton("验证信息");b2=new JButton("删除");b3=new JButton("退出");
     		p3.add(b1);p3.add(b2);p3.add(b3);
     		frame.add(p3,BorderLayout.CENTER);
     		
     		//根据输入显示学生信息
     		b1.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				
     			}
     		});
    
     		//根据输入删除学生信息
     		b2.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				JOptionPane.showMessageDialog(null,"已删除");
     				tf1.setText("");tf2.setText("");
     				tf3.setText("");tf4.setText("");
     			}
     		});
     		
     		//返回管理员用户界面
     		b3.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				p3.setVisible(false);
     				p1.setVisible(true);p2.setVisible(true);
     			}
     		});
     		
     	}
     });
    
     //删除教师信息
     b8.addActionListener(new ActionListener() {
     	public void actionPerformed(ActionEvent e) {
     		p2.setVisible(false);
     		
     		p3=new JPanel(new FlowLayout());
     		
     		//设置标签,文本框,按钮布局
     		l1=new JLabel("教师工号");l1.setPreferredSize(new Dimension(200,30));
     		tf1=new JTextField();tf1.setPreferredSize(new Dimension(300,30));
     		p3.add(l1);p3.add(tf1);
     		
     		l2=new JLabel("教师姓名");l2.setPreferredSize(new Dimension(200,30));
     		tf2=new JTextField();tf2.setPreferredSize(new Dimension(300,30));
     		p3.add(l2);p3.add(tf2);
     		
     		JLabel null1=new JLabel();
     		null1.setPreferredSize(new Dimension(50,30));
     		p3.add(null1);
     		
     		b1=new JButton("验证信息");b2=new JButton("删除");b3=new JButton("退出");
     		p3.add(b1);p3.add(b2);p3.add(b3);
     		frame.add(p3,BorderLayout.CENTER);
     		
     		//根据输入显示教师信息
     		b1.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				
     			}
     		});
    
     		//根据输入删除教师信息
     		b2.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				JOptionPane.showMessageDialog(null,"已删除");
     				tf1.setText("");tf2.setText("");
     			}
     		});
     		
     		//返回管理员用户界面
     		b3.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				p3.setVisible(false);
     				p1.setVisible(true);p2.setVisible(true);
     			}
     		});
     		
     	}
     });
    
     //删除课程信息
     b9.addActionListener(new ActionListener() {
     	public void actionPerformed(ActionEvent e) {
     		p2.setVisible(false);
     		
     		p3=new JPanel(new FlowLayout());
     		
     		//设置标签,文本框,按钮布局
     		l1=new JLabel("课程号");l1.setPreferredSize(new Dimension(200,30));
     		tf1=new JTextField();tf1.setPreferredSize(new Dimension(300,30));
     		p3.add(l1);p3.add(tf1);
     		
     		l2=new JLabel("课程名");l2.setPreferredSize(new Dimension(200,30));
     		tf2=new JTextField();tf2.setPreferredSize(new Dimension(300,30));
     		p3.add(l2);p3.add(tf2);
     		
     		JLabel null1=new JLabel();
     		null1.setPreferredSize(new Dimension(50,30));
     		p3.add(null1);
     		
     		b1=new JButton("验证信息");b2=new JButton("删除");b3=new JButton("退出");
     		p3.add(b1);p3.add(b2);p3.add(b3);
     		frame.add(p3,BorderLayout.CENTER);
     		
     		//根据输入显示课程信息
     		b1.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				
     			}
     		});
    
     		//根据输入删除课程信息
     		b2.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				JOptionPane.showMessageDialog(null,"已删除");
     				tf1.setText("");tf2.setText("");
     			}
     		});
     		
     		//返回管理员用户界面
     		b3.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				p3.setVisible(false);
     				p1.setVisible(true);p2.setVisible(true);
     			}
     		});
     		
     	}
     });
    
     //按需求查询成绩
     b10.addActionListener(new ActionListener() {
     	public void actionPerformed(ActionEvent e) {
     		p2.setVisible(false);
     		
     		p3=new JPanel(new FlowLayout());
     		
     		//设置标签,文本框,按钮布局
     		l1=new JLabel("请输入专业班级");l1.setPreferredSize(new Dimension(200,30));
     		tf1=new JTextField();tf1.setPreferredSize(new Dimension(300,30));
     		p3.add(l1);p3.add(tf1);
    
     		l2=new JLabel("请输入课程名");l2.setPreferredSize(new Dimension(200,30));
     		tf2=new JTextField();tf2.setPreferredSize(new Dimension(300,30));
     		p3.add(l2);p3.add(tf2);
    
     		JScrollPane jscrollpane=new JScrollPane();
     		Object[] columnNames=new Object[]{"课程号","课程名","学生学号","学生姓名","学生成绩"};//列名
     		Object[][] rowData=new Object[300][5];//行数,列数
     		 JTable table=new JTable(rowData,columnNames);
     		jscrollpane.setViewportView(table);
     		table.setRowHeight(25);
     		DefaultTableCellRenderer r = new DefaultTableCellRenderer();    
     		r.setHorizontalAlignment(JLabel.CENTER);   
     		table.setDefaultRenderer(Object.class,r);
     		p3.add(jscrollpane);
     		
     		b1=new JButton("显示成绩");b2=new JButton("退出");
     		p3.add(b1);p3.add(b2);
     		frame.add(p3,BorderLayout.CENTER);
     		
     		//根据输入显示学生成绩
     		b1.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				if(tf1.getText().equals("") && tf2.getText().equals("")) {
     					JOptionPane.showMessageDialog(null,"信息不完整,请重新输入");
     					tf1.setText("");
     				}
     			}
     		});
     		
     		//返回管理员用户界面
     		b2.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				p3.setVisible(false);
     				p1.setVisible(true);p2.setVisible(true);
     			}
     		});
     		
     	}
     });
    
     //显示所有学生成绩,并按一定规则排序
     b11.addActionListener(new ActionListener() {
     	public void actionPerformed(ActionEvent e) {
     		p2.setVisible(false);
     		
     		p3=new JPanel(new FlowLayout());
     		
     		//设置标签,文本框,按钮布局
     		JScrollPane jscrollpane=new JScrollPane();
     		Object[] columnNames=new Object[]{"课程号","课程名","学生学号","学生姓名","学生成绩"};//列名
     		Object[][] rowData=new Object[300][5];//行数,列数
     		JTable table=new JTable(rowData,columnNames);
     		jscrollpane.setViewportView(table);
     		table.setRowHeight(25);
     		DefaultTableCellRenderer r = new DefaultTableCellRenderer();    
     		r.setHorizontalAlignment(JLabel.CENTER);   
     		table.setDefaultRenderer(Object.class,r);
     		p3.add(jscrollpane);
     		
     		b1=new JButton("退出");
     		p3.add(b1);
     		frame.add(p3,BorderLayout.CENTER);
     		
     		//返回管理员用户界面
     		b1.addActionListener(new ActionListener() {
     			public void actionPerformed(ActionEvent e) {
     				p3.setVisible(false);
     				p1.setVisible(true);p2.setVisible(true);
     			}
     		});
     		
     	}
     });
    
     //返回登录界面
     b12.addActionListener(new ActionListener() {
     	public void actionPerformed(ActionEvent e) {
     		new Login();
     		frame.setVisible(false);
     	}
     });
     frame.setSize(550,750);
     frame.setVisible(true);
     frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    

    }

}

©️2021 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值