• Post Reply Bookmark Topic Watch Topic
  • New Topic

rendering the jcheckbox in jtable

 
ajay abcde
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi

i am able to get the value of the check box in the jtable cells but its not showing the checkbox. can anyone tell me how is it possible to show the checkbox in jtable
 
Rish Jain
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Use Editor to show it. You can create a class extending AbstractCellEditor, create a instance of your checkbox inside it and override getTableCellEditorComponent method. And return your checkbox instance from this method.

hope it wud help you.

cheers,
Rish
 
Brian Cole
Author
Ranch Hand
Posts: 920
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by ajay abcde:
i am able to get the value of the check box in the jtable cells but its not showing the checkbox. can anyone tell me how is it possible to show the checkbox in jtable


I'm not sure what you mean by the first half of that sentence but you may want to take a look at this thread from last week.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont know what table model you are using. By default, the getColumnClass() returns Object.class which is the root of the checkbox not being displayed problem. The solution is to over ride it by something like this:

Object getColumnClass(int columnIndex){
return super.getValueAt(0,columnIndex).getClass();
}

Best of luck.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!