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

📄 stuinfo.java

📁 班级管理系统
💻 JAVA
字号:
package lab.lab;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class StuInfo extends JFrame implements ActionListener{
	Container contentPane;
	JPanel centerPanel =new JPanel();
	JPanel upPanel=new JPanel();
	JPanel downPanel=new JPanel();
	Dimension faceSize=new Dimension(800,500);
	JLabel jlabel1=new JLabel();
	JLabel jlabel2=new JLabel();
	JLabel jlabel3=new JLabel();
	JLabel jlabel4=new JLabel();
	JLabel jlabel5=new JLabel();
	JLabel jlabel6=new JLabel();
	JLabel jlabel7=new JLabel();
	JLabel jlabel8=new JLabel();
	JLabel jlabel9=new JLabel();
	JTextField sNum=new JTextField(15);
	JTextField sName=new JTextField(15);
	JTextField sSex=new JTextField(15);
	JTextField sSethnic=new JTextField(15);
	JTextField sBirth=new JTextField(15);
	JTextField sYear=new JTextField(15);
	JTextField sMajor=new JTextField(15);
	JTextField sCollege=new JTextField(15);
	JTextField sHome=new JTextField(46);
	JButton searchInfo=new JButton();
	JButton addInfo=new JButton();
	JButton deleteInfo=new JButton();
	JButton modifyInfo=new JButton();
	JButton clearInfo=new JButton();
	JButton saveInfo=new JButton();
	JButton exitInfo=new JButton();
	GridBagLayout gridBag=new GridBagLayout();
	GridBagConstraints gridBagCon;
	public StuInfo(){
		this.setSize(faceSize);
		this.setTitle("学生管理信息");
		this.setResizable(false);
        try{
        	Init();
        }
        catch(Exception e){
        	e.printStackTrace();
        }
	}
	public void Init()throws Exception{
		contentPane=this.getContentPane();
		contentPane.setLayout(new BorderLayout());
		centerPanel.setLayout(gridBag);
		jlabel1.setText("学                 号");
		jlabel1.setFont(new Font("Dialog",0,12));
		gridBagCon=new GridBagConstraints();
		gridBagCon.gridx=0;
		gridBagCon.gridy=0;
		gridBagCon.insets=new Insets(10,10,10,1);
		gridBag.setConstraints(jlabel1,gridBagCon);
		centerPanel.add(jlabel1);
		gridBagCon=new GridBagConstraints();
		gridBagCon.gridx=1;
		gridBagCon.gridy=0;
		gridBagCon.insets=new Insets(10,1,10,15);
		gridBag.setConstraints(sNum,gridBagCon);
		centerPanel.add(sNum);
		
		jlabel2.setText("姓                 名");
		jlabel2.setFont(new Font("Dialog",0,12));
		gridBagCon=new GridBagConstraints();
		gridBagCon.gridx=2;
		gridBagCon.gridy=0;
		gridBagCon.insets=new Insets(10,15,10,1);
		gridBag.setConstraints(jlabel2,gridBagCon);
		centerPanel.add(jlabel2);
		gridBagCon=new GridBagConstraints();
		gridBagCon.gridx=3;
		gridBagCon.gridy=0;
		gridBagCon.insets=new Insets(10,1,10,10);
		gridBag.setConstraints(sName,gridBagCon);
		centerPanel.add(sName);
		
		jlabel3.setText("性                 别");
		jlabel3.setFont(new Font("Dialog",0,12));
		gridBagCon=new GridBagConstraints();
		gridBagCon.gridx=0;
		gridBagCon.gridy=1;
		gridBagCon.insets=new Insets(10,10,10,1);
		gridBag.setConstraints(jlabel3,gridBagCon);
		centerPanel.add(jlabel3);
		gridBagCon=new GridBagConstraints();
		gridBagCon.gridx=1;
		gridBagCon.gridy=1;
		gridBagCon.insets=new Insets(10,1,10,15);
		gridBag.setConstraints(sSex,gridBagCon);
		centerPanel.add(sSex);
		
		jlabel4.setText("民                 族");
		jlabel4.setFont(new Font("Dialog",0,12));
		gridBagCon=new GridBagConstraints();
		gridBagCon.gridx=2;
		gridBagCon.gridy=1;
		gridBagCon.insets=new Insets(10,15,10,1);
		gridBag.setConstraints(jlabel4,gridBagCon);
		centerPanel.add(jlabel4);
		gridBagCon=new GridBagConstraints();
		gridBagCon.gridx=3;
		gridBagCon.gridy=1;
		gridBagCon.insets=new Insets(10,1,10,10);
		gridBag.setConstraints(sSethnic,gridBagCon);
		centerPanel.add(sSethnic);
		
		jlabel5.setText("出     生    日    期");
		jlabel5.setFont(new Font("Dialog",0,12));
		gridBagCon=new GridBagConstraints();
		gridBagCon.gridx=0;
		gridBagCon.gridy=2;
		gridBagCon.insets=new Insets(10,10,10,1);
		gridBag.setConstraints(jlabel5,gridBagCon);
		centerPanel.add(jlabel5);
		gridBagCon=new GridBagConstraints();
		gridBagCon.gridx=1;
		gridBagCon.gridy=2;
		gridBagCon.insets=new Insets(10,1,10,15);
		gridBag.setConstraints(sBirth,gridBagCon);
		centerPanel.add(sBirth);
		
		jlabel6.setText("入    学     时    间");
		jlabel6.setFont(new Font("Dialog",0,12));
		gridBagCon=new GridBagConstraints();
		gridBagCon.gridx=2;
		gridBagCon.gridy=2;
		gridBagCon.insets=new Insets(10,15,10,1);
		gridBag.setConstraints(jlabel6,gridBagCon);
		centerPanel.add(jlabel6);
		gridBagCon=new GridBagConstraints();
		gridBagCon.gridx=3;
		gridBagCon.insets=new Insets(10,1,10,10);
		gridBag.setConstraints(sYear,gridBagCon);
		centerPanel.add(sYear);
		
		jlabel7.setText("学                 院");
		jlabel7.setFont(new Font("Dialog",0,12));
		gridBagCon=new GridBagConstraints();
		gridBagCon.gridx=0;
		gridBagCon.gridy=3;
		gridBagCon.insets=new Insets(10,10,10,1);
		gridBag.setConstraints(jlabel7,gridBagCon);
		centerPanel.add(jlabel7);
		gridBagCon=new GridBagConstraints();
		gridBagCon.gridx=1;
		gridBagCon.gridy=3;
		gridBagCon.insets=new Insets(10,1,10,15);
		gridBag.setConstraints(sCollege,gridBagCon);
		centerPanel.add(sCollege);
		
		jlabel8.setText("专                 业");
		jlabel8.setFont(new Font("Dialog",0,12));
		gridBagCon=new GridBagConstraints();
		gridBagCon.gridx=2;
		gridBagCon.gridy=3;
		gridBagCon.insets=new Insets(10,15,10,1);
		gridBag.setConstraints(jlabel8,gridBagCon);
		centerPanel.add(jlabel8);
		gridBagCon=new GridBagConstraints();
		gridBagCon.gridx=3;
		gridBagCon.gridy=3;
		gridBagCon.insets=new Insets(10,1,10,10);
		gridBag.setConstraints(sMajor,gridBagCon);
		centerPanel.add(sMajor);
		
		jlabel9.setText("籍                 贯");
		jlabel9.setFont(new Font("Dialog",0,12));
		gridBagCon=new GridBagConstraints();
		gridBagCon.gridx=0;
		gridBagCon.gridy=4;
		gridBagCon.insets=new Insets(10,10,10,1);
		gridBag.setConstraints(jlabel9,gridBagCon);
		centerPanel.add(jlabel9);
		gridBagCon=new GridBagConstraints();
		gridBagCon.gridx=1;
		gridBagCon.gridy=4;
		gridBagCon.gridwidth=3;
		gridBagCon.insets=new Insets(10,1,10,10);
		gridBag.setConstraints(sHome,gridBagCon);
		centerPanel.add(sHome);
		
		contentPane.add(centerPanel,BorderLayout.CENTER);
		
		sNum.setEditable(false);
		sName.setEditable(false);
		sSex.setEditable(false);
		sSethnic.setEditable(false);
		sBirth.setEditable(false);
		sYear.setEditable(false);
		sMajor.setEditable(false);
		sCollege.setEditable(false);
		sHome.setEditable(false);	
	}
	public void downInit(){
		searchInfo.setText("查询");
		searchInfo.setFont(new Font("Dialog",0,12));
		downPanel.add(searchInfo);
		addInfo.setText("增加");
		addInfo.setFont(new Font("Dialog",0,12));
		downPanel.add(addInfo);
		modifyInfo.setText("修改");
		modifyInfo.setFont(new Font("Dialog",0,12));
		downPanel.add(modifyInfo);
		deleteInfo.setText("删除");
		deleteInfo.setFont(new Font("Dialog",0,12));
		downPanel.add(deleteInfo);
		saveInfo.setText("保存");
		saveInfo.setFont(new Font("Dialog",0,12));
		downPanel.add(saveInfo);
		clearInfo.setText("清空");
		clearInfo.setFont(new Font("Dialog",0,12));
		downPanel.add(clearInfo);
		exitInfo.setText("退出");
		exitInfo.setFont(new Font("Dialog",0,12));
		downPanel.add(exitInfo);
		contentPane.add(downPanel,BorderLayout.SOUTH);
		
		searchInfo.addActionListener(this);
		addInfo.addActionListener(this);
		modifyInfo.addActionListener(this);
		deleteInfo.addActionListener(this);
		saveInfo.addActionListener(this);
		clearInfo.addActionListener(this);
		exitInfo.addActionListener(this);
		
		modifyInfo.setEnabled(false);
		deleteInfo.setEnabled(false);
		saveInfo.setEnabled(false);
		clearInfo.setEnabled(false);
	}
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		Object obj=e.getSource();
		if(obj==searchInfo){			
		}
		else if(obj==addInfo){
		}
		else if(obj==modifyInfo){			
		}
		else if(obj==deleteInfo){
		}
		else if(obj==saveInfo){
		}
		else if(obj==clearInfo){
			setNull();
		}
		else if(obj==exitInfo){
			this.dispose();
		}
	}
	void setNull(){
		sNum.setText(null);
		sName.setText(null);
		sSex.setText(null);
		sSethnic.setText(null);
		sBirth.setText(null);
		sYear.setText(null);
		sMajor.setText(null);
		sCollege.setText(null);
		sHome.setText(null);
	}
}

⌨️ 快捷键说明

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