aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Unselect all buttons in a JToggleButton ButtonGroup Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Unselect all buttons in a JToggleButton ButtonGroup" Watch "Unselect all buttons in a JToggleButton ButtonGroup" New topic
Author

Unselect all buttons in a JToggleButton ButtonGroup

Chrissy Simpson
Greenhorn

Joined: Jul 17, 2002
Posts: 22
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

Joined: Jul 17, 2002
Posts: 22
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unselect all buttons in a JToggleButton ButtonGroup
 
Similar Threads
JRadioButton question
Button Group
ButtonGroup problem
JRadioButton : Deselecting
two really important questions