62,616
社区成员
发帖
与我相关
我的任务
分享
package tools;
import javax.swing.table.AbstractTableModel;
public class StuTable extends AbstractTableModel {
public StuTable(){
}
@Override
public int getColumnCount() {
// TODO Auto-generated method stub
return this.tableHead.size();
}
@Override
public int getRowCount() {
// TODO Auto-generated method stub
return this.tableData.size();
}
@Override
public Object getValueAt(int row, int col) {
// TODO Auto-generated method stub
return this.tableData.get(row).get(col);
}
public String getColumnName(int col){
return this.tableHead.get(col);
}
@Override
public Class<?> getColumnClass(int col) {
// TODO Auto-generated method stub
return this.getValueAt(0, col).getClass();
}
@Override
public boolean isCellEditable(int row, int col) {
// TODO Auto-generated method stub
return false;
}
@Override
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
// TODO Auto-generated method stub
this.tableData.get(rowIndex).set(columnIndex, aValue);
}
public class BrowsePanel extends JScrollPane {
private StuTable tableModel = null;
private JTable table = null;
private JScrollPane pane = null;
public BrowsePanel(){
tableModel = new StuTable();
table = new JTable();
table.setModel(tableModel);
this.setBorder(BorderFactory.createTitledBorder("浏览学生信息"));
this.setViewportView(table);
this.updateUI();
}
public void freshUI(){
table.setModel(tableModel);
this.updateUI();
}
public StuTable getTableModel() {
return tableModel;
}
public JTable getTable() {
return table;
}
}
public void freshUI(){
table.setModel(tableModel);
this.updateUI();
}