小鱼宝宝 - 云代码空间
——
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { |
if(jTextField2.getText().equals("")){ |
JOptionPane.showMessageDialog(null, "请输入姓名!"); |
}else{ |
try { |
String names = jTextField2.getText(); |
ArrayList<Subject> list = Start_table_name.getAllSubject(names); |
//查询将要显示的值,按照name查询 |
String[] hds = { "编号", "姓名", "语文成绩", "英语成绩", "数学成绩" }; |
dtm.setColumnIdentifiers(hds); |
dtm.getDataVector().clear(); |
Object[][] data = new Object[list.size()][hds.length]; |
for (int i = 0; i < list.size(); i++) { |
Subject subject = list.get(i); |
data[i][0] = subject.getId(); |
data[i][1] = subject.getName(); |
data[i][2] = subject.getChinese(); |
data[i][3] = subject.getEnglish(); |
data[i][4] = subject.getMath(); |
dtm.addRow(data[i]); |
System.out.print(subject.getId()); |