?? studentinfotable.java
字號:
package Sys.vo;
import java.util.Iterator;
import javax.swing.JTable;
import java.util.*;
import javax.swing.table.DefaultTableModel;
public class StudentInfoTable extends JTable{
private static final long serialVersionUID = 1L;
private String []columnNames={"序列","學號","姓名","性別","年齡","種族","出生日期","班級","入學時間"};
private DefaultTableModel tableModel;
public StudentInfoTable(){
tableModel = new DefaultTableModel(columnNames, 0) {
private static final long serialVersionUID = 1L;
public boolean isCellEditable(int row, int col) {
return false;//表格不允許編輯
}
};
this.setModel(tableModel);
this.setVisible(true);
}
public void setContents(List<StudentInfo> list){
int i=0;
Iterator<StudentInfo> iter = list.iterator();
while (iter.hasNext()) {
StudentInfo studnetinfo=iter.next();//這里因為要獲得同一個StudentInfo對象的多個值,就這樣來
i++;
String []content={String.valueOf(i),studnetinfo.getStudentID(),studnetinfo.getStudentName()
,studnetinfo.getSex(),studnetinfo.getAge(),studnetinfo.getFamily()
,studnetinfo.getBirthday(),studnetinfo.getClassID()
,studnetinfo.getBeginTime()};
tableModel.addRow(content);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -