[java]代码库
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());
}
} catch (Exception e) {
// TODO: handle exception
JOptionPane.showMessageDialog(null, "请输入姓名!");
}
[源代码打包下载]
初级程序员
by: 芋头 发表于:2016-05-31 16:55:59 顶(0) | 踩(0) 回复
真好!
网友回复
回复我真的很帅 : 真的假的
顶(0) 踩(0) 2019-10-30 17:13:22
回复评论