• Post Reply Bookmark Topic Watch Topic
  • New Topic

insert the jcheckbox into jtable

 
ajay abcde
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can anyone tell me how can i insert the jcheckbox inside the jtable
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
google keywords
JTable JCheckBox

a wealth of information
 
Brian Cole
Author
Ranch Hand
Posts: 920
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by ajay abcde:
can anyone tell me how can i insert the jcheckbox inside the jtable


The easy way to do this is just to make sure you return
Boolean.class in your table model's getColumnClass()
method for the columns in which you want check boxes. (If
you don't have your own table model class this probably
means subclassing DefaultTableModel, perhaps anonymously.)
The table will then use check box cell renderers and cell
editors automatically.

[edit: I should have mentioned that your table model needs to
return Boolean.TRUE or Boolean.FALSE from its getValueAt() method.]

If you want some cells with and without check boxes in the
same column then you will have to create your own cell
renderer and (unless they are read-only) cell editor.
[ July 20, 2007: Message edited by: Brian Cole ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!