| Author |
modifying default renderer for Boolean class
|
Nadin Jovan
Greenhorn
Joined: Aug 12, 2003
Posts: 7
|
|
I am trying to modify the default renderer for Boolean class to disable certain JCheckBox cells in a table. I overwrote the method getCellRenderer as follows: public TableCellRenderer getCellRenderer(int row, int col) { if (col == 0) return this.getDefaultRenderer(String.class); if (!this.getModel().isCellEditable(row, col)) { TableCellRenderer renderer = this.getDefaultRenderer(Boolean.class); if (renderer instanceof JCheckBox) { JCheckBox box = (JCheckBox)renderer; box.setEnabled(false); box.setBorderPaintedFlat(true); //box.setForeground(Color.LIGHT_GRAY); //box.setBackground(Color.BLUE); } return renderer; } return this.getDefaultRenderer(Boolean.class); } I would expect this to render all uneditable cells as disabled JCheckBoxes, but it didn't. Any ideas what I might be doing wrong? Thanks.
|
 |
Tamizh Selvan
Greenhorn
Joined: Oct 10, 2003
Posts: 15
|
|
hi you can try overriding the belo method. public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column); Hope this w'd help u. Tamizh
|
"No one knows what one can do until one tries"<br />-John Kingsley.
|
 |
 |
|
|
subject: modifying default renderer for Boolean class
|
|
|