• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JTable

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
[Thumbnail for tabel.jpg]
tabel
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)....
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
use an appropriate renderer for that column's tableHeader
 
K. Tsang
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic