我想用列名做一个 JTable,使用:
JTable(Vector rowData, Vector columnNames)
to 构造一个 JTable 以显示向量中的值,rowData,列名,columnNames。
所以,我这样做了:
final String[] columnNames = {"NOMBRE", "DÍAS DE LA SEMANA", "HORA DE INICIO", "HORA DE FIN", "TIEMPO MÁXIMO DE USO"};
rs.last();
int numRows = rs.getRow();
rs.beforeFirst();
Object[][] columnData = new String[numRows][5];
int i = 0;
while(rs.next()){
columnData[i][0] = rs.getString(1);
columnData[i][1] = rs.getString(2);
columnData[i][2] = rs.getString(3);
columnData[i][3] = rs.getString(4);
columnData[i][4] = rs.getString(5);
}
table = new JTable(columnData, columnNames);
table.setBounds(300,600,700,150);
但是我只看到数据,为什么没有显示标题?
预先感谢