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 JTable with RadioButton Headers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable with RadioButton Headers" Watch "JTable with RadioButton Headers" New topic

JTable with RadioButton Headers

jefff willis
Ranch Hand

Joined: Sep 29, 2004
Posts: 113
I've seen examples of JTables with push button header examples. They work well enough but I could really use a RadioButton header.

Has anyone ever don't anything like that?

I'm including some code that I use for a push button header. I've tried to adapt a RadioButton header from this code but I have had much luck.

Tim McGuire
Ranch Hand

Joined: Apr 30, 2003
Posts: 820

I got radio buttons to show up in your table headers by having it extend JRadioButton instead of JButton:
You will need change the listener to work better with radio buttons.
jefff willis
Ranch Hand

Joined: Sep 29, 2004
Posts: 113
Thanks Tim,

Thanks for the help.

My problem with the RadioButton example is that I can't seem to get them to "group."

When I press Column 1 for example, I want the other columns to be un-selected.

I'm in the process of implementing that in my mouse listener, but I was kind of hoping that the SWING components would do this for me.
I agree. Here's the link:
subject: JTable with RadioButton Headers
It's not a secret anymore!