Hey guys, I'm having a few problems with a JTable subclass I'm making. The constructor:
When I call addRow(), it gives me an array index out of bounds exception if I do not call the bolded line. However, when I do call that line, I get duplicate columns appearing (one in the table model, one in the column model). I tried not adding the column to the column model, and that works, but then when the column is displayed only via the table model, any custom cell renderers I use don't work, and the column doesn't display the header value I set it to either (just displays the toString() of the TableColumn object).
Any help? What is the proper way to add columns?
Code:
public CustomTable()
{
super();
TableColumn col = new TableColumn();
col.setCellRenderer(new CustomCellRenderer());
col.setHeaderValue("Blah");
DefaultTableModel model = ((DefaultTableModel)getModel());
[B]model.addColumn(col);[/B]
getColumnModel().addColumn(col);
}
Any help? What is the proper way to add columns?
Comment