Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

CheckBoxRenderer  RSS feed

 
Krish smith
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
facing problem in using CheckBoxRenderer in treeTable.
used code to invoke Renderer:
treeTable.setDefaultRenderer(Boolean.class,
new CheckBoxRenderer ());
Is there anything wrong with the above call


public class CheckBoxRenderer extends JCheckBox
implements TableCellRenderer {
public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected,
boolean hasFocus, int row, int column) {
setSelected(((Boolean)value).booleanValue()));
return this;
}
}
 
Krish smith
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
checkbox in treeTable is not editable...i added code for making it editable. Is there anything else i need to do.
public boolean isCellEditable(Object node, int column) {
switch (column) {
case 0:
// Allow editing of the name, as long as not the root.
return (node != getRoot());
default:
return true;
}
}
 
Brian Cole
Author
Ranch Hand
Posts: 935
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure you are returning Boolean.class
in your model's getColumnClass() method.

You shouldn't have to create your own
renderer and call setDefaultRenderer()
unless you want to.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!