当前位置:首页 > 基于Java和Oracle的学生信息管理系统
学生信息管理系统
自己做的学生信息管理系统,由于能力有限,其中的错误和不足较多,但可以正常运行也加入了必要的提示操作,希望能为有需要的童鞋一些启示。
附录:学生信息管理系统代码
1.登录界面 1.1登录界面模块 //函数库
import java.awt.*; import javax.swing.*; import java.awt.event.*; import java.sql.*; //登录界面主程序
public class system extends JFrame implements ActionListener {
private static final long serialVersionUID = 1L; static system ss;
JPanel panel = new JPanel(); JMenuBar jmb1 = new JMenuBar(); JMenuBar mBar=new JMenuBar(); JMenu Help = new JMenu(\帮 助 \JMenu About = new JMenu(\关 于 \
JMenuItem Password = new JMenuItem(\忘 记 密 码\JMenuItem Aboutus = new JMenuItem(\关 于 软 件\//设置姓名、密码、登陆、退出按钮 JLabel label1 = new JLabel(\账 号\JTextField usernumber = new JTextField(); JLabel label2 = new JLabel(\密 码\
JPasswordField pwd = new JPasswordField(); JButton Enter = new JButton(\登 录\JButton Exit = new JButton(\退 出\//设置主题图片
String url = \ButtonGroup bgp = new ButtonGroup();
1
//设置学生、教师角色,并设置角色按钮 JRadioButton stu = new JRadioButton(\学 生\JRadioButton tch = new JRadioButton(\教 师\public system() {
//设置窗口题头
super(\学生管理系统\ this.setSize(500,400); this.setResizable(false); panel.setOpaque(false); this.setJMenuBar(jmb1);
JLabel img = new JLabel(new ImageIcon(url)); img.setBounds(0,0,575,70); Password.addActionListener(this); Aboutus.addActionListener(this); setJMenuBar(jmb1);
//向面板中一次添加图片、按钮,并设置按钮尺寸 jmb1.add(Help); jmb1.add(About); Help.add(Password); About.add(Aboutus); mBar.add(Help); mBar.add(About); setJMenuBar(mBar); panel.add(img);
stu.setBounds(210,150,70,30); tch.setBounds(310,150,70,30); bgp.add(stu); bgp.add(tch); panel.add(stu); panel.add(tch);
Enter.setBounds(210,180,70,20); Exit.setBounds(290,180,70,20); Enter.addActionListener(this);
2
Exit.addActionListener(this); Help.setForeground(Color.blue); Password.setForeground(Color.blue); About.setForeground(Color.blue); Aboutus.setForeground(Color.blue); panel.add(Enter); panel.add(Exit); panel.setLayout(null); this.add(panel);
label1.setBounds(175,90,50,25); panel.add(label1);
usernumber.setBounds(210,90,150,25); panel.add(usernumber);
label2.setBounds(175,125,50,25); panel.add(label2);
pwd.setBounds(210,125,150,25); panel.add(pwd);
this.setBounds(110,60,540,320); //将当前窗口防止在屏幕中央 setLocationRelativeTo(null); //setVisible(true); this.setVisible(true);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
@SuppressWarnings(\ public void actionPerformed(ActionEvent e) {
String id , password; id= usernumber.getText(); password = pwd.getText(); if(e.getSource()==Password)
JOptionPane.showMessageDialog(this,\请联系任课教师重置密码\忘记密码\ if(e.getSource()==Aboutus)
3
! JOptionPane.showMessageDialog(this,\作 者: 张三\\n\\n单 位: 信 息 工 程 学 院\\n\\n版 本: Version 1.1.8\关于软件\ if(e.getSource()==Exit) {System.exit(0);} if(e.getSource()==Enter) {
//加载数据库驱动 try
{
Class.forName(\}
catch (ClassNotFoundException ce) { }
if(!(stu.isSelected())&&!(tch.isSelected())) {
JOptionPane.showMessageDialog(this,\请选择学生或教师!\}
else if(stu.isSelected()) {
if(id.equals(\如果没输账号或密码,则提
JOptionPane.showMessageDialog(ss,ce.getMessage());
示对不起,请输入账号或密码 {
JOptionPane.showMessageDialog(this,\对不起,你输入账号或密码为空!\ }
else//如果都有数据了就开始连接数据库验证 { try
{
Connection
4
con =
共分享92篇相关文档