File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes render a checkbox in a 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 "render a checkbox in a Jtable" Watch "render a checkbox in a Jtable" New topic

render a checkbox in a Jtable

Steeve Randria

Joined: Sep 17, 2010
Posts: 16
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
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> When a checkbox is checked, the other must become not checked...

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

Joined: Oct 27, 2005
Posts: 20193

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.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: render a checkbox in a Jtable
jQuery in Action, 3rd edition