Hi all,
I have a problem with a Checkbox in a JTable.
When i add the Checkbox into the JTable it displays the String
representation of the Checkbox, which is not what i want.
So, i created a CheckBoxRendere r which extens Checkbox and implements
TableCellRender er. This seems to have done the job, in that the Checkbox
is displayed and not the String representation. But, and it's a big
'but', the column that holds the Checkbox continually updates the
fields. I cannot select the Checkbox and i can only just see that the
correct info for the Checkbox is in the cell.
I think it has something to do with repainting the Checkbox, but i can't
figure out how to stop it from happening.
Many thanx.
Ben
Here is some of the code, the bit's i think are relevent:
All code is at:
http://www.users.on.net/benmunday/Label/
public class CheckBoxRendere r extends Checkbox implements TableCellRender er
{
....
public Component getTableCellRen dererComponent( JTable table, Object
cBox, boolean isSelected, boolean hasFocus, int row, int column)
{
Checkbox newCheckbox = (Checkbox)cBox;
newCheckbox.set State(false);
return newCheckbox;
}
}
JTable itemDataTable = new JTable(new MyTableModel(da ta));
itemDataTable.s etDefaultRender er(data[0][0].getClass(),
new CheckBoxRendere r());
itemDataScrollP ane.getViewport ().setView(item DataTable);
itemDataScrollP ane.setVisible( true);
contentPane.add (itemDataScroll Pane, BorderLayout.CE NTER);