jQuery in Action, 3rd edition
The moose likes Swing / AWT / SWT and the fly likes JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable" Watch "JTable" New topic
Author

JTable

adrei boadrei
Greenhorn

Joined: Nov 24, 2012
Posts: 5
Hello dear friends.
In JFrame i have one JTable .how i can do Title 1 is replaced by checkbox?



[tabel.jpg]

K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 3042
    
    9

How are you getting or generating your column name? Do you using the default table model or making your own?


K. Tsang JavaRanch SCJP5 SCJD OCPJP7 OCPWCD5 OCPBCD5 OCPWSD5 OCMJEA5 part 1 part 2/3
adrei boadrei
Greenhorn

Joined: Nov 24, 2012
Posts: 5
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

Joined: Jun 09, 2003
Posts: 4632
use an appropriate renderer for that column's tableHeader
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 3042
    
    9

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

Joined: Oct 27, 2005
Posts: 20129
    
  30

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTable
 
It's not a secret anymore!