Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTable with RadioButton Headers

 
jefff willis
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic