• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTable

 
adrei boadrei
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello dear friends.
In JFrame i have one JTable .how i can do Title 1 is replaced by checkbox?
tabel.jpg
tabel
[Thumbnail for tabel.jpg]
 
K. Tsang
Bartender
Posts: 3404
13
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you getting or generating your column name? Do you using the default table model or making your own?
 
adrei boadrei
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
K. Tsang wrote:How are you getting or generating your column name? Do you using the default table model or making your own?


i want to make my own table ....but instead of string"title 1" must be checkbox
table contents -checkbox (Title1), Name(Title2), LastName(Title3)....
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use an appropriate renderer for that column's tableHeader
 
K. Tsang
Bartender
Posts: 3404
13
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
adrei boadrei wrote:
K. Tsang wrote:How are you getting or generating your column name? Do you using the default table model or making your own?


i want to make my own table ....but instead of string"title 1" must be checkbox
table contents -checkbox (Title1), Name(Title2), LastName(Title3)....


In your table model, you should override the getColumnName() method and assign a empty string "" to it. Then in your getColumnClass() method, return Boolean.class for that column. This should give what you want.
 
Rob Spoor
Sheriff
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That would work for the JTable itself, but the JTableHeader needs special support. Apart from the renderer Michael talked about you would also require a listener (probably MouseListener) to handle the toggling.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic