This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes JTable and JRadioButtons Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "JTable and JRadioButtons" Watch "JTable and JRadioButtons" New topic
Author

JTable and JRadioButtons

Lina Mahl
Greenhorn

Joined: Jul 02, 2002
Posts: 13
My JTable is not showing my JRadioButtons?
I am using a TableModel and there i do have a method called "public Class getColumnClass(int c)"
What am I doing wrong?
Eduard Jodas
Ranch Hand

Joined: May 14, 2002
Posts: 80
If you want a radio button to be showing on the JTable as a cell, you need to provide it through a TableCellRenderer. TableCellRenderers are provided either by TableColumn or cell value Class.
Thus, I would access the desired TableColumn (through the TableColumnModel) and set its TableCellRenderer.
In addition to this, if you want this radio button to be editable, you should provide a TableCellEditor as well.
Moreover, if only one radio button can be selected in the whole column, make sure the whole column is repainted when selection changes.
But why do you need the radio button? To select the flight to book seats for? That can be accomplished by allowing single selection of the table rows. It is much easier than having radio buttons.
 
Don't get me started about those stupid light bulbs.
 
subject: JTable and JRadioButtons