Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unselect all buttons in a JToggleButton ButtonGroup

 
Chrissy Simpson
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Everyone. i have a set of JToggleButtons in a ButtonGroup and I want to change the behaviour of the ButtonGroup to unselect all buttons in the group when an already selected toggle button is clicked again. I know that this is not behaviour that ButtonGroup supports, however in the javadoc for ButtonGroup, it suggest to add an invisible button to the group and programmatically select that button when you want to unselect all button. That is not a problem. My problem is that I cannot figure out a way to detect if a button is already selected. If I use an action event, then no matter what the previous state was, isSelected() returns true. I am lost and tired. Any ideas? thanks.
 
Chrissy Simpson
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is amazing what a fresh day can do. I am now just keeping track of the last two buttons pressed so I can determine if all the buttons should be unselected. It would still be nice if anyone knows a way I can do this without tracking the previous action but it is not a big deal.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic