It's not a secret anymore!
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes state of radio button. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "state of radio button." Watch "state of radio button." New topic

state of radio button.

geetha nagarajan
Ranch Hand

Joined: Jul 13, 2001
Posts: 94

Checkbox cb1 and cb3 have their state set to true.
At //1 : Checkbox cb3 is set to belong to CheckboxGroup cbg.
When,this is compiled and run,they appear as radio buttons,but both cb1 and cb3 are selected.
Are they not radiobuttons in the true sense?
Is it necessary to set the Checkbox to a CheckboxGroup in it's constructor itself ,to ensure mutually exclusive nature?
Francisco A Guimaraes
Ranch Hand

Joined: Mar 20, 2002
Posts: 182
geetha, I changed your code a little bit:

now it only shows "lotus" as selected, but if you select any of the other 2, "lotus" is still selected, this was the best I could do. I´┐Żll let you know if I discover a better solution or why does this happen.

Francisco<br />SCJP<br />please use the [code][/code] tags when showing code.Click <a href="" target="_blank" rel="nofollow">here</a> to see an example.
geetha nagarajan
Ranch Hand

Joined: Jul 13, 2001
Posts: 94
Thanks Francisco.
So,i guess for all practical purposes to ensure mutually exclusive nature for radiobutton,the Checkbox should be set with the reqd. CheckboxGroup in the constructor itself.
Swati Gupta
Ranch Hand

Joined: May 28, 2002
Posts: 106
No, we can set the group using setCheckboxGroup().The above code should have the last one as selected checkbox.
I agree. Here's the link:
subject: state of radio button.
It's not a secret anymore!