DefaultTableModel

Swing填充表格的类

 DefaultTableModel dtm = (DefaultTableModel) bookTypeTable.getModel();
  dtm.setRowCount(0);
  Connection con = null;
  try {
   con = dbUtil.getCon();
   ResultSet rs = bookTypeDao.getBookTypeList(con,bookType);
   while (rs.next()) {
    Vector v = new Vector();
    v.add(rs.getInt("id"));
    v.add(rs.getString("bookTypeName"));
    v.add(rs.getString("bookTypeDetail"));
    dtm.addRow(v);

   }

.addRow(v) 方法结合Vector类来实现表格填充

posted on 2013-06-10 17:02  ' 华丽の转身 &、  阅读(568)  评论(0编辑  收藏  举报