Java Geeks (Esp bartender!!!)... Today I was messing up with Checkbox and CheckboxGroup. I was able to create 3 radio button with all three enabled!!!.. *** ALL RIGHTS ARE RESERVED... I GOT COPYRIGHTS TO TELL THIS TO SUN!!! ***
OUTPUT in my case was : 3 RADIO BUTTON ("CHICS" , "BABE" , "BLONDE" , "hot") all enabled.
[This message has been edited by maha anna (edited April 10, 2000).]
Tony Alicea
Desperado
Sheriff
Joined: Jan 30, 2000
Posts: 3219
posted
0
I only saw a blank screen. [This message has been edited by Tony Alicea (edited April 10, 2000).]
Tony Alicea Senior Java Web Application Developer, SCPJ2, SCWCD
Jesper Ottosson
Ranch Hand
Joined: Mar 21, 2000
Posts: 51
posted
0
tony, i think you're supposed to send stuff through the commandline. Ok, psethura, i tried it, and i see your point... The java api says this:
Exactly one check box button in a CheckboxGroup can be in the "on" state at any given time. Pushing any button sets its state to "on" and forces any other button that is in the "on" state into the "off" state.
So, i don't think it's really clear whether the one-at-a-time rule should be used always, or just when someone pushes a radiobutton. On the other hand, the radiobuttons behave quite weird when you use them at first, so perhaps something is wrong.
Anonymous
Ranch Hand
Joined: Nov 22, 2008
Posts: 18944
posted
0
Thanks Jasper..
Anonymous
Ranch Hand
Joined: Nov 22, 2008
Posts: 18944
posted
0
Well psethura, I tried your code. There is a learning in this I believe. 1)When you pass the CheckBoxGroup to the constructor, only the last RadioButton is checked. 2)When the checkbox is constructed, and no value for enabling the checkbox as in c[i] = new Checkbox(arr[i] ); Nothing is checked. 3) As in your case, first you have created the checkboxes. As in this case, all of them will be checked by default. So if you now have to set a checkboxgroup, I believe you have to manually take care that only one of them is checked. [This message has been edited by Lionel (edited May 31, 2000).]
Ray Marsh
Ranch Hand
Joined: Jan 12, 2000
Posts: 458
posted
0
I tried your code and got the same result. I found when I clicked the radio buttons off and select them, one at a time, the check box would go off for the previously selected button, automatically. Which is the correct behavior. It seems initializing them to true interferes with this. I even tried initializing only the first one to true, but it still would not un-check automatically. Setting them all to false works fine, however, if you want a default button set on then you'll need a different approach to get the correct behavior. I haven't gotten this to work, yet.
Anxiety does not empty tomorrow of its sorrows, but only empties today of its strength. – Charles Spurgeon