The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
January 2002

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Three ways

Posted by Hiran on January 17, 2002 at 5:42 PM

As far as I can see, you can do it three ways. The first is to use the setSelected method on all the buttons every time. The second is to use variables to keep track of which one is currently selected. So, you could have an array of integers, with 0 meaning not pressed and 1 meaning pressed, and the array starts of initialized to 0, and whenever a button is pressed, the corresponding array element is set to 1 (and back to 0 when the button is reset). The third way (which I though of as I was writing this and I realize that this way is the easiest and most efficient) is to use the isSelected method. That returns the state of the button. Just check (using the isSelected method) whether any of the buttons are selected, and then unselect that one whenever you want.
Hiran

> Yes i'm looking for that, but i don't know how identify whick button of the buttongroup i i've pressed. When i do that i can apply the setSelected method to the button.






Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us