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

目录

继续

点击学生信息系统即可进入此窗体。由studentmanageframe.java实现 如图

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

实现的代码如下:

[cce]import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import java.util.Vector;
import javax.swing.*;
///这是一个学生信息系统的入口框架类。
///studentframe是顶层窗口框架。
///通过七个按钮控件来分别可以进入到不同班级、不同系的学生信息系统中。
///七个按钮控件分别产生七个不同的动作事件简史事件,分别进入不同的信息系统。
///在布局方面有两个布局管理器,一个是lay即网格组布局。一个是jp是GridLayout布局。
///通过不同的SQL语句进入不同的班级和系的管理系统。
class studentmanageframe extends JPanel
{
private static final long serialVersionUID = 1L;
static final int WIDTH=290;
static final int HEIGHT=250;
static JFrame studentframe;

private static studentmanageframe instance;

public static studentmanageframe getInstance()
{
if ( instance == null )
{
instance = new studentmanageframe();
return instance;
}
else
{    studentframe.setVisible(true);
return instance;

}
}

private studentmanageframe()
{
studentframe=new JFrame();
studentframe.setTitle("学生信息管理系统");
studentframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
studentframe.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;
studentframe.setLocation(x,y);
studentframe.setVisible(true);
studentframe.setResizable(false);

studentframe.add(this, BorderLayout.CENTER);

JButton computerone=new JButton("学生基本信息管理");
JButton computertwo=new JButton("学生课程管理");
JButton computerthree=new JButton("学生成绩管理");
JButton bioone=new JButton("返回");

computerone.setSize(140,50);
computerone.setLocation(80,0);

computertwo.setSize(140,50);
computertwo.setLocation(80,50);

computerthree.setSize(140,50);
computerthree.setLocation(80,100);

bioone.setSize(140,50);
bioone.setLocation(80,150);
//JButton mechone=new JButton("5");
//JButton mechtwo=new JButton("6");
//JButton mechthree=new JButton("7");
JLabel title=new JLabel("学生信息系统主界面");
JLabel banket1=new JLabel();
JLabel banket2=new JLabel();
//GridBagLayout lay=new GridBagLayout();
studentframe.setLayout(null);
// GridBagConstraints constraints=new GridBagConstraints();
// constraints.fill=GridBagConstraints.NONE;
//constraints.anchor=GridBagConstraints.EAST;
//constraints.weightx=2;
//constraints.weighty=5;
JPanel jp=new JPanel();
//jp.setLayout(new GridLayout(1,3));
jp.add(banket1);
jp.add(title);
jp.add(banket2);
studentframe.add(jp,BorderLayout.NORTH);
studentframe.add(computerone); //,constraints,1,1,1,1                //使用网格组布局添加控件
studentframe.add(computertwo);//,constraints,1,2,1,1
studentframe.add(computerthree);//,constraints,1,3,1,1
studentframe.add(bioone);//,constraints,1,4,1,1
//add(mechone,constraints,1,1,1,1);
//add(mechtwo,constraints,1,2,1,1);
// add(mechthree,constraints,1,3,1,1);
///单击这个按钮,进入到学生基本信息管理
computerone.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent Event)
{
studentinfo    student=studentinfo.getInstance("学生基本信息管理","select * from info ");

}
});
///单击这个按钮,进入到学生课程管理
computertwo.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent Event)
{
studentcou addfr=studentcou.getInstance("学生课程信息管理","select * from course ");

}
});
///单击这个按钮,进入到学生成绩管理
computerthree.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent Event)
{
studentmark addfr=studentmark.getInstance("学生成绩信息管理","select * from mark ");

}
});
///单击这个按钮,隐藏窗体
bioone.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent Event)
{
studentframe.setVisible(false);
}
});

}
public void add(Component c,GridBagConstraints constraints,int x,int y,int w,int h)
{
constraints.gridx=x;
constraints.gridy=y;
constraints.gridwidth=w;
constraints.gridheight=h;
add(c,constraints);
}
//public static void main(String[] args){
// studentmanageframe log=new studentmanageframe();}
}