This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply 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
Ranch Hand

Joined: Sep 13, 2007
Posts: 1219

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
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
Ranch Hand

Joined: Sep 13, 2007
Posts: 1219

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: 19216

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