aspose file tools*
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: 2416
    
    7

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/OCM-JD OCPJP7 OCPWCD5
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: 2416
    
    7

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: 19693
    
  20

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
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTable