I have a jTable displaying a simple two column sql table's data and allowing a user to maintain the list. This is my first java program. Have that working such that user can edit the list of data and press save to update.
I get the sql data to the jTable's DefaultTableModel from this line of code:
paCutAboveTable.SetTableModel((DefaultTableModel) DbUtils.resultSetToTableModel(rs));
I'm guessing DBUtils and resultSets are familiar to people here.
I want to add a CheckBox to each row. Looking here and elsewhere I kept seeing to subclass DefaultTableModel in order to override a method thus:
/*
* JTable uses this method to determine the default renderer/
* editor for each cell. If we didn't implement this method,
* then the last column would contain text ("true"/"false"),
* rather than a check box.
*/
public Class getColumnClass(int c) {
return getValueAt(0, c).getClass();
}
However I can't figure how to get the output of DefaultTableModel from resultSetToTableModel method to my subclass - the statement shown doesn't compile if the SetTableModel method is changed to accept the subclass as its parameter.
Is there an easy way I'm missing?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…