ButtonGroup and JToggleButton. Need help.

Ok so i have a simple question. How can i deselect all JToggleButtons that are currently selected in my ButtonGroup with a line of code?

I have tried many things like JToggleButton.setSelected(false); and have searched google for like an hour coming up empty. If anyone can please help me out i would much appreciate it.

Just loop through the buttons and set them.

yes but HOW do i set them is what im trying to figure out. I dont know how to set them to not selected.

setSelected() should work as far as I know. You could also try setEnabled(false).


ButtonGroup group = ...;
Enumeration<AbstractButton> buttons = group.getElements();
while (buttons.hasMoreElements())
	buttons.nextElement().setSelected(false);