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.

[1821 byte] By [suddu_cha] at [2007-10-3 10:10:27]
# 1
Learn a simple and standard way from: http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#editrender
hiwaa at 2007-7-15 5:30:22 > top of Java-index,Desktop,Core GUI APIs...
# 2
Quit cluttering the forums. You posted the same question 13 minutes earlier.If you really want help learn to use the forum correctly. For example learn how to post code using the "Code" formattting tags so the code is actually readable.
camickra at 2007-7-15 5:30:22 > top of Java-index,Desktop,Core GUI APIs...
# 3
sorry camickr,That was my first forum .which i have posted.Thats the reason it happend like that!!Please don't mind this.Thanks.
suddu_cha at 2007-7-15 5:30:22 > top of Java-index,Desktop,Core GUI APIs...