[java]代码库private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
if(jTextField2.getText().equals("")){
JOptionPane.showMessageDialog(null, "请输入姓名!");
}else{
try {
String names = jTextField2.getText();
ArrayList 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());
}
} catch (Exception e) {
// TODO: handle exception
JOptionPane.showMessageDialog(null, "请输入姓名!");
}
[源代码打包下载]
Form-table.zip(50积分)[80 次下载]