aspose file tools
The moose likes Swing / AWT / SWT and the fly likes modifying default renderer for Boolean class Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "modifying default renderer for Boolean class" Watch "modifying default renderer for Boolean class" New topic
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.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: modifying default renderer for Boolean class
 
Similar Threads
getTableCellRendererComponent() in Jtable-doubt(urgent please)
JTable - JDBC - Vectors
Adding checkbox to some selected row of a column.
Make String display bold or italic
Cannot uncheck JCheckBox in JTable