M
Mark Sizzler
When I google for "JTable JCheckbox cell" I get thousands of hits but they
do not explain on how to put a JCheckBox into all cells of a column and how
to retrieve the current status (checked/unchecked) from it.
As I understand I have to replace the current DefaultRenderer by
my own Renderer class. Currently my JTable is defined similar to:
myJTable = new JTable(myTableModel) {
public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
Component component = super.prepareRenderer(renderer,row,column);
if (isRowSelected(row))
component.setBackground(Color.blue);
else if (((String)getValueAt(row,column)).equals("Test"))
component.setBackground(Color.yellow);
else
component.setBackground(Color.white);
return component; }
};
How can I extend this code with the necessary JCheckBox additions?
Mark
do not explain on how to put a JCheckBox into all cells of a column and how
to retrieve the current status (checked/unchecked) from it.
As I understand I have to replace the current DefaultRenderer by
my own Renderer class. Currently my JTable is defined similar to:
myJTable = new JTable(myTableModel) {
public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
Component component = super.prepareRenderer(renderer,row,column);
if (isRowSelected(row))
component.setBackground(Color.blue);
else if (((String)getValueAt(row,column)).equals("Test"))
component.setBackground(Color.yellow);
else
component.setBackground(Color.white);
return component; }
};
How can I extend this code with the necessary JCheckBox additions?
Mark