panelforstatus.java
来自「学生学籍管理系统」· Java 代码 · 共 785 行 · 第 1/2 页
JAVA
785 行
package E4;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import java.text.*;
import javax.swing.table.*;
import javax.swing.event.MouseInputListener;
import javax.swing.table.AbstractTableModel;
import javax.swing.event.*;
class panelForStatus extends JPanel implements ActionListener,TextListener,ItemListener,TableModelListener,ListSelectionListener
{
JPanel jplForFrame_2= new JPanel();
JPanel jplForFrame2_1=new JPanel();
Panel jplForFrame2_2=new Panel();
JPanel jplForFrame2_3=new JPanel();
JPanel jplForFrame2_4=new JPanel();
public static int jishu;
Table_Model tm = new Table_Model();
JTable table;
public static int tableRow = 0;
public static int tableColumn = 0;
JPopupMenu popupMenu=new JPopupMenu(); //鼠标右键
JMenuItem deleteRow=new JMenuItem("删除此行记录");
JMenuItem deleteStuInfor=new JMenuItem("删除学籍");
JMenuItem findInfor=new JMenuItem("查找记录");
JMenuItem compositor=new JMenuItem("排序");
public static JLabel showNum;
JPanel jplForFrame_1=new JPanel();
JPanel jplForFrame_3=new JPanel();
JPanel forAddCenter = new JPanel();
JButton find = new JButton("查找");
JButton delete = new JButton("删除");
JButton setClear = new JButton("清空");
JButton refresh = new JButton("刷新");
JButton confirm = new JButton("确认提交");
JRadioButton jrb_male=new JRadioButton("男");
JRadioButton jrb_female=new JRadioButton("女");
ButtonGroup sex= new ButtonGroup();
public static Object Infor[]=new Object[16];
Choice birthYear,birthMonth,birthDay,nation,eductionalSystem,languageType,degree,
entranceYear,entranceMonth,entranceDay,politicsType,college,classes;
// 学籍信息包括:学号,姓名,姓名简拼,性别,出生日期,民族,籍贯,政治面貌,
TextField name,id,birthPlace,testPlace,graduateSchool,totalScore;
//入学日期,学生类别,系所,班名,学制,专业(下拉表?),外语语种,考区,
//毕业中学,高考总分,学位,学科门类,培养方式,因材施教,专来方向,分流方向,
//0id,1name,2sex,3birthPlace,4testPlace,5graduateSchool,6totalScore
//7birthDate,8nation,9eductionalSystem,10languageType,11degree,
//12entranceDate16entranceDay,13politicsType,14college,15classes
public static String snations[]= {"汉族","满族","回族","朝鲜族","土家族","苗族","藏族","维吾尔族","蒙古族","其它"};
public static String educateSys[] ={"四年制","五年制","硕本连读","其它"};
public static String foreignLan[] ={"英语","日语","俄语","其它"};
Nation one ;
Delete_1 del_1;
Search_1 sea_1;
proceeSQL psql = new proceeSQL();
ListSelectionModel selectionMode=null;
panelForStatus(JFrame jfm){
psql.openSQL();
this.setVisible(true);
one = new Nation(jfm,"民族",false);
del_1 = new Delete_1(jfm,"删除学籍信息",false);
sea_1 = new Search_1(jfm,"查找学籍信息",false);
birthYear = new Choice();//添加年龄设置
for(int i=0;i<20;i++){birthYear.addItem(""+(1975+i));}
//Infor[7]=birthYear.getSelectedItem();
birthMonth = new Choice();
for(int i=0;i<12;i++){birthMonth.addItem(""+(i+1));}
//Infor[8]=birthMonth.getSelectedItem();
birthDay = new Choice();
for(int i=0;i<31;i++){birthDay.addItem(""+(i+1));}
// Infor[9]=birthDay.getSelectedItem();
nation = new Choice();
for(int i=0;i<10;i++)nation.addItem(snations[i]);
Infor[8]=nation.getSelectedItem();
eductionalSystem = new Choice();
for(int i=0;i<4;i++)eductionalSystem.addItem(educateSys[i]);
Infor[9]=eductionalSystem.getSelectedItem();
languageType = new Choice();
for(int i=0;i<4;i++)languageType.addItem(foreignLan[i]);
Infor[10]=languageType.getSelectedItem();
degree = new Choice();degree.addItem("学士");degree.addItem("硕士");
Infor[11]=degree.getSelectedItem();
college = new Choice();
college.addItem("计算机科学与技术");
college.addItem("网络工程");
college.addItem("软件工程");
college.addItem("会计学");
college.addItem("国际贸易");
college.addItem("光电子");
college.addItem("机械自动化");
college.addItem("环境工程");
classes = new Choice();
for(int i=3;i<7;i++)
for(int j=0;j<4;j++)
classes.addItem("计算机科学与技术0"+i+(j+1)+"班");
Infor[14] = college.getSelectedItem();
Infor[15] = classes.getSelectedItem();
entranceYear = new Choice();for(int i=0;i<20;i++){entranceYear.addItem(""+(1997+i));}
entranceMonth = new Choice(); for(int i=0;i<12;i++){entranceMonth.addItem(""+(i+1));}
entranceDay = new Choice();for(int i=0;i<31;i++){entranceDay.addItem(""+(i+1));}
politicsType = new Choice();politicsType.addItem("团员");politicsType.addItem("党员");politicsType.addItem("无");
Infor[13]=politicsType.getSelectedItem();
jishu = psql.getStudentInfor(tm.content);
tm.addTableModelListener(this);
table=new JTable(tm);
showNum=new JLabel("总数为:"+jishu);
selectionMode=table.getSelectionModel();//取得table的ListSelectionModel.
selectionMode.addListSelectionListener(this);
popupMenu.add(deleteRow);
popupMenu.addSeparator();
popupMenu.add(deleteStuInfor);
popupMenu.addSeparator();
popupMenu.add(findInfor);
popupMenu.addSeparator();
popupMenu.add(compositor);
deleteRow.addActionListener(this);
deleteStuInfor.addActionListener(this);
findInfor.addActionListener(this);
compositor.addActionListener(this);
MouseInputListener mil = new MouseInputListener() {
public void mouseClicked(MouseEvent e) {
processEvent(e);
}
public void mousePressed(MouseEvent e) {
processEvent(e);
}
public void mouseReleased(MouseEvent e) {
processEvent(e);
if ((e.getModifiers() & MouseEvent.BUTTON3_MASK) != 0) {
popupMenu.show(table, e.getX(), e.getY());
}
}
public void mouseEntered(MouseEvent e) {
processEvent(e);
}
public void mouseExited(MouseEvent e) {
processEvent(e);
}
public void mouseDragged(MouseEvent e) {
processEvent(e);
}
public void mouseMoved(MouseEvent e) {
processEvent(e);
}
private void processEvent(MouseEvent e) {
if ((e.getModifiers() & MouseEvent.BUTTON3_MASK) != 0) {
MouseEvent ne = new MouseEvent(
e.getComponent(), e.getID(),
e.getWhen(), MouseEvent.BUTTON1_MASK,
e.getX(), e.getY(), e.getClickCount(), false);
table.dispatchEvent(ne);
}
}
};
table.addMouseListener(mil);
table.addMouseMotionListener(mil);
jplForFrame_2.setLayout(new BorderLayout());
jplForFrame_2.add(jplForFrame2_1,BorderLayout.NORTH);
jplForFrame_2.add(jplForFrame2_2,BorderLayout.WEST);
jplForFrame_2.add(jplForFrame2_3);
jplForFrame_2.add(jplForFrame2_4,BorderLayout.SOUTH);
name=new TextField("",6);
id =new TextField("",8);
birthPlace=new TextField("",19);
testPlace=new TextField("",9);
graduateSchool=new TextField("",19);
totalScore=new TextField("",5);
jplForFrame2_1.setLayout(new FlowLayout(FlowLayout.LEFT));
jplForFrame2_1.add(new JLabel("学号:",JLabel.CENTER));
jplForFrame2_1.add(id);
jplForFrame2_1.add(new JLabel("姓名:",JLabel.CENTER));
jplForFrame2_1.add(name);
jplForFrame2_1.add(new JLabel("姓别:",JLabel.CENTER));
JPanel pnl=new JPanel();
sex.add(jrb_male);
sex.add(jrb_female);
pnl.add(jrb_male);
pnl.add(jrb_female);
jplForFrame2_1.add(pnl);
jplForFrame2_1.add(new JLabel("出生日期:"));
jplForFrame2_1.add(birthYear);jplForFrame2_1.add(new JLabel("年",JLabel.LEFT));
jplForFrame2_1.add(birthMonth);jplForFrame2_1.add(new JLabel("月",JLabel.LEFT));
jplForFrame2_1.add(birthDay);jplForFrame2_1.add(new JLabel("日",JLabel.LEFT));
jplForFrame2_2.setLayout(new GridLayout(4,2,2,16));
jplForFrame2_2.add(new JLabel("民族:",JLabel.CENTER));jplForFrame2_2.add(nation);
jplForFrame2_2.add(new JLabel("学制:",JLabel.CENTER));jplForFrame2_2.add(eductionalSystem);
jplForFrame2_2.add(new JLabel("外语语种:"));jplForFrame2_2.add(languageType);
jplForFrame2_2.add(new JLabel("学位:",JLabel.CENTER));jplForFrame2_2.add(degree);
Panel jplForFrame2_3_1 = new Panel();
Panel jplForFrame2_3_2 = new Panel();
Panel jplForFrame2_3_3 = new Panel();
Panel jplForFrame2_3_4 = new Panel();
Panel jplForFrame2_3_5 = new Panel();
Panel jplForFrame2_3_6 = new Panel();
Panel jplForFrame2_3_7 = new Panel();
Panel jplForFrame2_3_8 = new Panel();
jplForFrame2_3_2.add(new JLabel(" 籍贯:",JLabel.LEFT));jplForFrame2_3_2.add(birthPlace);
jplForFrame2_3_1.add(new JLabel("入学日期:",JLabel.LEFT));
jplForFrame2_3_1.add(entranceYear);
jplForFrame2_3_1.add(new JLabel("年"));jplForFrame2_3_1.add(entranceMonth);
jplForFrame2_3_1.add(new JLabel("月"));jplForFrame2_3_1.add(entranceDay);
jplForFrame2_3_1.add(new JLabel("日"));
jplForFrame2_3_3.add(new JLabel("政治面貌:"));jplForFrame2_3_3.add(politicsType);
jplForFrame2_3_4.add(new JLabel("高考考区:"));jplForFrame2_3_4.add(testPlace);
jplForFrame2_3_5.add(new JLabel("毕业中学:"));jplForFrame2_3_5.add(graduateSchool);
jplForFrame2_3_6.add(new JLabel("高考总分:"));jplForFrame2_3_6.add(totalScore);
jplForFrame2_3_7.add(new JLabel("选择院系:"));jplForFrame2_3_7.add(college);
jplForFrame2_3_8.add(new JLabel("选择班级")); jplForFrame2_3_8.add(classes);
jplForFrame2_3_2.setLayout(new FlowLayout(FlowLayout.LEFT,9,2));
jplForFrame2_3_3.setLayout(new FlowLayout(FlowLayout.LEFT,9,2));
jplForFrame2_3_4.setLayout(new FlowLayout(FlowLayout.LEFT,9,2));
jplForFrame2_3_5.setLayout(new FlowLayout(FlowLayout.LEFT,9,2));
jplForFrame2_3_6.setLayout(new FlowLayout(FlowLayout.LEFT,9,2));
jplForFrame2_3_7.setLayout(new FlowLayout(FlowLayout.LEFT,9,2));
jplForFrame2_3_8.setLayout(new FlowLayout(FlowLayout.LEFT,9,2));
jplForFrame2_3.add(jplForFrame2_3_2);
jplForFrame2_3.add(jplForFrame2_3_1);
jplForFrame2_3.add(jplForFrame2_3_3);
jplForFrame2_3.add(jplForFrame2_3_4);
jplForFrame2_3.add(jplForFrame2_3_5);
jplForFrame2_3.add(jplForFrame2_3_6);
jplForFrame2_3.add(jplForFrame2_3_7);
jplForFrame2_3.add(jplForFrame2_3_8);
jplForFrame2_3.setLayout(new GridLayout(4,4,2,2));
birthYear.addItemListener(this);
birthMonth.addItemListener(this);
birthDay.addItemListener(this);
nation.addItemListener(this);
eductionalSystem.addItemListener(this);
languageType.addItemListener(this);
degree.addItemListener(this);
entranceYear.addItemListener(this);
entranceMonth.addItemListener(this);
entranceDay.addItemListener(this);
politicsType.addItemListener(this);
jrb_male.addItemListener(this);
jrb_female.addItemListener(this);
college.addItemListener(this);
classes.addItemListener(this);
name.addTextListener(this);
id.addTextListener(this);
birthPlace.addTextListener(this);
testPlace.addTextListener(this);
graduateSchool.addTextListener(this);
totalScore.addTextListener(this);
setClear.addActionListener(this);
confirm.addActionListener(this);
refresh.addActionListener(this);
find.addActionListener(this);
delete.addActionListener(this);
del_1.pDelePer.handin.addActionListener(this);
del_1.pDelePer.find.addActionListener(this);
del_1.pDeleCla.handin.addActionListener(this);
del_1.pDeleAll.handin.addActionListener(this);
del_1.pDeleCol.handin.addActionListener(this);
one.confirm.addActionListener(this);
sea_1.pfsi.handin.addActionListener(this);
sea_1.pfsn.handin.addActionListener(this);
sea_1.pfscla.handin.addActionListener(this);
sea_1.pfsco.handin.addActionListener(this);
sea_1.pfsnation.handin.addActionListener(this);
jplForFrame_1.add(find);
jplForFrame_1.add(delete);
jplForFrame_1.add(setClear);
jplForFrame_1.add(refresh);
jplForFrame_1.add(showNum);
jplForFrame_1.setLayout(new GridLayout(9,1,8,9));
forAddCenter.setLayout(new BorderLayout(5,6));
forAddCenter.add(jplForFrame_2,BorderLayout.NORTH);
jplForFrame_3.setLayout(new FlowLayout(FlowLayout.RIGHT,9,9));
jplForFrame_3.add(confirm);
forAddCenter.add(jplForFrame_3,BorderLayout.SOUTH);
forAddCenter.add(new JScrollPane(table));
super.setLayout(new BorderLayout(9,2));
super.add(jplForFrame_1,BorderLayout.WEST);
super.add(forAddCenter);
}
public void valueChanged(ListSelectionEvent el){
tableRow =table.getSelectedRow();
tableColumn =table.getSelectedColumn();
// label.setText("修改字段位置:"+(row+1)+" 行 "+(column+1)+" 列");
}
public void tableChanged(TableModelEvent e)
{
int row =e.getFirstRow();
int column = e.getColumn();
Infor[0] = tm.getValueAt(row,1);
Infor[1] = tm.getValueAt(row,2);
Infor[2] = tm.getValueAt(row,3);
Infor[3] = tm.getValueAt(row,4);
Infor[4] = tm.getValueAt(row,5);
Infor[5] = tm.getValueAt(row,6);
Infor[6] = tm.getValueAt(row,7);
Infor[7] = tm.getValueAt(row,8);
Infor[8] = tm.getValueAt(row,9);
Infor[9] = tm.getValueAt(row,10);
Infor[10] = tm.getValueAt(row,11);
Infor[11] = tm.getValueAt(row,12);
Infor[12] = tm.getValueAt(row,13);
Infor[13] = tm.getValueAt(row,14);
Infor[14] = tm.getValueAt(row,15);
Infor[15] = tm.getValueAt(row,16);
psql.updateStuInforDetail(Infor);
shuaxin();
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==confirm)
{
psql.insertStuInforDetail(Infor);
panelForCourse.setIdAndName(id.getText(),name.getText());
shuaxin();
}
else if(e.getSource()==one.confirm){
Infor[10]=one.returnNation();
one.setDisplay(false);
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?