• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

render a checkbox in a Jtable

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I have a problem for rendering a checkbox in a JTable
I have a JTable wich contains 2 lines and one column
These lines are filled with an object Greetings that contains a string (typeMessage) and a boolean(etat) that I filled in a model by the return of a boolean method.
If the boolean returned is true, line 1 or 2 is checked according the result.
I would change the checkbox checked when i click on a line (not on a checkbox). When a checkbox is checked, the other must become not checked but i can ' t do it.

Here is my renderer:


Thank you in advance for your help.
Ps: Sorry for my english
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> When a checkbox is checked, the other must become not checked...

a recent thread here at the ranch, with a link to the solution

http://www.coderanch.com/t/510484/GUI/java/Help-JCheckBox-JTable-return-value
 
Sheriff
Posts: 21759
102
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the Javadoc of JTable. It has a link to a page of the Java Swing Tutorial on how to use JTables. I believe there is a section on renderers / editors. In short, if your TableModel returns Boolean.class for a column you don't need to change a thing; JTable will automatically use a check box for that column.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!