Java 大作业之学生信息管理系统—The Three

目录

接着上面继续讲

学生信息管理主界面模块是由maniframe.java主窗口类实例化,进入其他的窗体。验证登陆后就可进入此窗体。

Java 大作业之学生信息管理系统—The Three

实现的代码如下:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
///这是一个主界面的类。
///student是指进入学生信息系统的界面控件
///teacher是指进入教师信息系统的界面控件
///leader是指进入领导信息系统的界面控件
///后面紧接着就是这个三个控件的动作事件的监视方法,分别是进入三个不同的系统
class mainframe
{
static final int WIDTH=290;
static final int HEIGHT=250;
JFrame buttonframe;
private JMenuBar mb ;//声明工具栏
private JMenu query,alter,delete,abouthelp,insert;//声明菜单
private JMenuItem q1,q2,q3,q4,q5,q6,a1,a2,a3,a4,a5,a6,d1,d2,d3,info,about,i1,i2,i3,i4;//菜单选项
public mainframe()
{
buttonframe=new JFrame();
buttonframe.setTitle("信息管理系统");
buttonframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//
buttonframe.setSize(WIDTH,HEIGHT);
Toolkit kit=Toolkit.getDefaultToolkit();
Dimension screenSize=kit.getScreenSize();
int width=screenSize.width;
int height=screenSize.height;
int x=(width-WIDTH)/2;
int y=(height-HEIGHT)/2;
buttonframe.setLocation(x,y);
buttonframe.setVisible(true);
buttonframe.setResizable(false);
JMenuBar jMenuBar1 = new JMenuBar();
mb= new JMenuBar();//声明菜单栏

query= new JMenu("窗口");//声明菜单

insert=new JMenu("添加");
abouthelp=new JMenu("帮助");

q1=new JMenuItem("学生基本信息");//菜单项
q2=new JMenuItem("学生课程管理");
q3=new JMenuItem("学生成绩管理");
q4=new JMenuItem("教师信息管理");
q5=new JMenuItem("退出");

i1=new JMenuItem("学生基本信息");
i2=new JMenuItem("学生课程信息");
i3=new JMenuItem("学生成绩信息");
i4=new JMenuItem("教师信息管理");

info=new JMenuItem("系统说明");
about=new JMenuItem("关于作者");

mb.add(query);//添加菜单项

mb.add(insert);
mb.add(abouthelp);

query.add(q1);//添加下拉菜单
query.add(q2);
query.add(q3);
query.add(q4);
query.add(q5);

insert.add(i1);
insert.add(i2);
insert.add(i3);
insert.add(i4);

abouthelp.add(info);
abouthelp.add(about);

JButton student=new JButton("学生信息系统");
JButton teacher=new JButton("教师信息系统");
JButton leader=new JButton("管理员信息系统");
JButton cancel=new JButton("退出");
student.setSize(130,50);
student.setLocation(80,0);
teacher.setSize(130,50);
teacher.setLocation(80,50);
leader.setSize(130,50);
leader.setLocation(80,100);
cancel.setSize(130,50);
cancel.setLocation(80,150);
buttonframe.add(student);
buttonframe.add(teacher);
buttonframe.add(leader);
buttonframe.add(cancel);
buttonframe.setJMenuBar(mb);//设置菜单栏
buttonframe.setLayout(null);//new GridLayout(3,1)
student.addActionListener(new ActionListener() //点击学生按钮
{
public void actionPerformed(ActionEvent Event)
{
//进入学生管理页面
studentmanageframe    student=studentmanageframe.getInstance();
//studentmanageframe student= new studentmanageframe();
// String sql="select username,name,sex,zhuanye,sushenumber,sushephone,qq,email from info ";
// studentinfo info=new studentinfo("学生基本信息管理",sql);
}
});
teacher.addActionListener(new ActionListener() //点击教师按钮
{
public void actionPerformed(ActionEvent Event)
{
teacherinfo addfr=teacherinfo.getInstance("教师基本信息管理","select * from teacher ");
}
});
leader.addActionListener(new ActionListener() //点击管理员按钮
{
public void actionPerformed(ActionEvent Event)
{
JOptionPane.showMessageDialog(null,"该功能正在开发中!", "Sorry",JOptionPane.ERROR_MESSAGE);
}
});
cancel.addActionListener(new ActionListener() //点击退出按钮
{
public void actionPerformed(ActionEvent Event)
{

System.exit(0);
}
});
info.addActionListener(new ActionListener()//系统说明
{
public void actionPerformed(ActionEvent Event)
{

try
{

String fileName="readme.txt";
Runtime rt = Runtime.getRuntime();
String exePath ="C:\\WINDOWS\\system32\\notepad.exe "+".\\" +fileName;
rt.exec(exePath); }
catch(Exception e)
{JOptionPane.showMessageDialog(null,e.getMessage(), "对不起,出错啦",JOptionPane.ERROR_MESSAGE);}
}
});

q1.addActionListener(new ActionListener()//打开学生基本信息
{
public void actionPerformed(ActionEvent Event)
{
studentinfo    student=studentinfo.getInstance("学生基本信息管理","select * from info");

}
});

q2.addActionListener(new ActionListener()//打开学生基本信息
{
public void actionPerformed(ActionEvent Event)
{
studentcou addfr=studentcou.getInstance("学生课程信息管理","select * from course");
//    String sql="select * from course ";

//   studentcou cou=new studentcou("学生课程管理",sql);

}
});

q3.addActionListener(new ActionListener()//打开学生成绩信息
{
public void actionPerformed(ActionEvent Event)
{

studentmark addfr=studentmark.getInstance("学生成绩信息管理","select * from mark");
//addmarkframe addfr=addmarkframe.getInstance();
//    String sql="select * from course ";

//   studentcou cou=new studentcou("学生课程管理",sql);

}
});

q4.addActionListener(new ActionListener()//打开学生成绩信息
{
public void actionPerformed(ActionEvent Event)
{

teacherinfo addfr=teacherinfo.getInstance("教师基本信息管理","select * from teacher ");
}
});

q5.addActionListener(new ActionListener()//退出系统
{
public void actionPerformed(ActionEvent Event)
{
System.exit(0);
}
});
i1.addActionListener(new ActionListener()//打开添加学生基本信息窗口
{
public void actionPerformed(ActionEvent Event)
{
addframe addfr=addframe.getInstance();

}
});

i2.addActionListener(new ActionListener()//打开添加学生课程管理窗口
{
public void actionPerformed(ActionEvent Event)
{
addcourseframe addcourse=addcourseframe.getInstance();

}
});

i3.addActionListener(new ActionListener()//打开添加学生成绩管理窗口
{
public void actionPerformed(ActionEvent Event)
{
addmarkframe addmark=addmarkframe.getInstance();
}
});

i4.addActionListener(new ActionListener()//打开添加教师信息管理窗口
{
public void actionPerformed(ActionEvent Event)
{
addteacherframe addtea=addteacherframe.getInstance();
}
});

about.addActionListener(new ActionListener()//打开添加作者博客
{
public void actionPerformed(ActionEvent Event)
{

try
{

String url="http://hi.baidu.com/caijiamx";
Runtime.getRuntime().exec("rundll32   url.dll,FileProtocolHandler   "   +   url);
// Runtime rt = Runtime.getRuntime();
// String exePath ="C:\\WINDOWS\\system32\\notepad.exe "+".\\" +fileName;
// rt.exec(exePath); }
}
catch(Exception e)
{JOptionPane.showMessageDialog(null,e.getMessage(), "对不起,出错啦",JOptionPane.ERROR_MESSAGE);}

}
});

}
//public static void main(String[] args){
//mainframe log=new mainframe();}

}