📄 clainfo.java
字号:
package lab.lab;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class ClaInfo 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 cNum=new JTextField(15);
JTextField cDept=new JTextField(15);
JTextField cMteacher=new JTextField(15);
JTextField cStunum=new JTextField(15);
JTextField cMoney=new JTextField(15);
JTextField cAttack=new JTextField(15);
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 ClaInfo(){
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(cNum,gridBagCon);
centerPanel.add(cNum);
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(cDept,gridBagCon);
centerPanel.add(cDept);
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(cMteacher,gridBagCon);
centerPanel.add(cMteacher);
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(cStunum,gridBagCon);
centerPanel.add(cStunum);
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(cMoney,gridBagCon);
centerPanel.add(cMoney);
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(cAttack,gridBagCon);
centerPanel.add(cAttack);
contentPane.add(centerPanel,BorderLayout.CENTER);
cNum.setEditable(false);
cDept.setEditable(false);
cMteacher.setEditable(false);
cStunum.setEditable(false);
cMoney.setEditable(false);
cAttack.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(){
cNum.setText(null);
cDept.setText(null);
cMteacher.setText(null);
cStunum.setText(null);
cMoney.setText(null);
cAttack.setText(null);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -