首页 新闻 搜索 专区 学院

java swing jtable 不能显示

0
悬赏园豆:10 [待解决问题]

private void displayResultSet(ResultSet rs) throws SQLException {
if (rs.next()) {
Vector rows = new Vector();
Vector columnHeads = new Vector();
try {
ResultSetMetaData rsmd = rs.getMetaData();
for (int i = 1; i <= rsmd.getColumnCount(); ++i)
columnHeads.addElement(rsmd.getColumnName(i));
do {
rows.addElement(getNextRow(rs, rsmd));
} while (rs.next());
JTable jTable = new JTable(rows, columnHeads);
jTable.setSize(new Dimension(383, 81));
JScrollPane scroller = new JScrollPane(jTable);
Container c = getContentPane();
c.remove(2);
c.add(scroller);
c.validate();
                               jTable.setVisible(true);
} catch (SQLException e) {
e.printStackTrace();
}
}
else{
return;
}

}

private Vector getNextRow(ResultSet rs, ResultSetMetaData rsmd)
throws SQLException {
Vector currentRow = new Vector();
for (int i = 1; i < rsmd.getColumnCount(); ++i)
currentRow.addElement(rs.getString(i));
return currentRow;
}

 

这是关于jtable的一个程序,但是查询数据时,jtable不能显示,帮忙看一下,什么问题?

swb2368559889的主页 swb2368559889 | 初学一级 | 园豆:194
提问于:2013-05-12 23:22
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册