How to implement button in a vector
Posted
by
user1880497
on Stack Overflow
See other posts from Stack Overflow
or by user1880497
Published on 2012-12-09T15:42:18Z
Indexed on
2012/12/09
17:04 UTC
Read the original article
Hit count: 170
In my table. I want to put some buttons into each row that I can press. But I do not know how to do it
public static DefaultTableModel buildTableModel(ResultSet rs)
throws SQLException {
java.sql.ResultSetMetaData metaData = rs.getMetaData();
// names of columns
Vector<String> columnNames = new Vector<String>();
int columnCount = metaData.getColumnCount();
for (int column = 1; column <= columnCount; column++) {
columnNames.add(metaData.getColumnName(column));
}
// data of the table
Vector<Vector<Object>> data = new Vector<Vector<Object>>();
while (rs.next()) {
Vector<Object> vector = new Vector<Object>();
for (int columnIndex = 1; columnIndex <= columnCount; columnIndex++) {
vector.add(rs.getObject(columnIndex));
}
data.add(vector);
}
return new DefaultTableModel(data, columnNames);
}
© Stack Overflow or respective owner