Problem with CustomCellRender && CustomCellEditor....
Hi to every one,
can any one help me to solve this problem.
I have a Custom cell renderer and custom cell editor.
so the requirement is i want a "Check Box" when the object is of type Boolean else I want "TextField".
->Like mixing of both "Check Box" and "Text Field".
please tell me where i should change my code..
here i am giving sample code:
class MyCellRenderer implements TableCellRenderer{
private JCheckBox jb;
public Component getTableCellRendererComponent(JTable table, Object obj, boolean isSelected, boolean hasFocus, int row, int column )
{
if(obj.getClass().getCanonicalName().equals("java.lang.Boolean"))
{
/* here i want a Check box */
jb=new JCheckBox("",Boolean.parseBoolean( obj.toString() ));
jb.setBackground(Color.WHITE);
jb.setHorizontalAlignment(JLabel.CENTER);
return jb;
}
else{
// here i want JTextField....
// it must return TextField...
}
}
}
class MyCellEditor implements TableCellEditor {
public Component getTableCellEditorComponent(JTable table,
Object obj, boolean isSelected,int row, int column){
if(obj.getClass().getCanonicalName().equals("java.lang.Boolean"))
{
/* here i want check box must be editable...when user click on the check box*/
JCheckBox jb=new JCheckBox("",Boolean.parseBoolean( obj.toString() ));
jb.setBackground(Color.WHITE);
jb.setHorizontalAlignment(JLabel.CENTER);
return jb;
}
else
{
// here i need to return JTextField and it must be editable.
}
}
}
Hope You understand what i said..
Please give replys on this. It is dead line for me...
ThankS...
Regards,
SUDARSHAN.

