I have this table model and I want to get Checkboxes in the first column. How can I do this? Do I have to make an extra column in my table?
ResultSetMetaData metaData = rs.getMetaData();
int numberOfColumns = metaData.getColumnCount();
Vector<String> columnNames = new Vector<String>();
for (int column = 0; column < numberOfColumns; column++) {
columnNames.addElement(metaData.getColumnLabel(column + 1));
}
rows = new Vector<Vector<Object>>();
while (rs.next()) {
Vector<Object> newRow = new Vector<Object>();
for (int i = 1; i <= numberOfColumns; i++) {
newRow.addElement(rs.getObject(i));
}
rows.addElement(newRow);
}
return new DefaultTableModel(rows, columnNames);
I already tried this. It is working, but I don't want to make an extra column in my table and I also want to have a Checkbox on the top which selects all other ons. Does anyone knows how it works?
table.getColumn("Select").setCellRenderer(
table.getDefaultRenderer(Boolean.class));