使用Eclipse不显示表头。如何解决这个问题?只有来自数据库的数据才是成功的。所以我把我试过的东西放在下面。

这是我用来显示数据库数据的代码:
void table_load() {
try {
pst = con.prepareStatement("select * from registation");
rs = pst.executeQuery();
table_1.setModel(DbUtils.resultSetToTableModel(rs));
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
table_1 = new JTable();
table_1.setBounds(448, 62, 383, 296);
frmStudentCrud.getContentPane().add(table_1);发布于 2020-11-27 04:38:44
未显示
表头
frmStudentCrud.getContentPane().add(table_1);只有在将表添加到滚动窗格并将滚动窗格添加到框架中时,才会显示标题。
您的代码应该是:
//frmStudentCrud.getContentPane().add(table_1);
JScrollPane scrollPane = new JScrollPane( table_1 );
frmStudentCrud.getContentPane().add( scrollPane );https://stackoverflow.com/questions/65031929
复制相似问题