ToggleGroup explicit management
Mark Fortner
phidias51 at gmail.com
Tue Apr 9 10:53:49 PDT 2013
I assume that if you add them one at a time, you don't have any problems,
right? If not, that would lead me to suspect that it's having problems
descriminating between instances of the RadioMenuItem -- perhaps hashcode
is improperly overridden. I use ToggleGroups with ToggleButtons all the
time without any problems.
Cheers,
Mark
On Tue, Apr 9, 2013 at 10:47 AM, Scott Palmer <swpalmer at gmail.com> wrote:
> No. (resend to include the list)
>
>
> On Tue, Apr 9, 2013 at 1:43 PM, Mark Fortner <phidias51 at gmail.com> wrote:
>
>> Does it work if you do this?
>>
>> toggleGroup.getToggles().addAll(new RadioMenuItem("One"), new
>> RadioMenuItem("Two")...);
>>
>> Cheers,
>>
>> Mark
>>
>>
>>
>> On Tue, Apr 9, 2013 at 10:29 AM, Scott Palmer <swpalmer at gmail.com> wrote:
>>
>>> The docs for ToggleGroup say:
>>> "Generally ToggleGroups are managed automatically simply by specifying
>>> the
>>> name of a ToggleGroup on the
>>> Toggle<
>>> http://docs.oracle.com/javafx/2/api/javafx/scene/control/Toggle.html>,
>>>
>>> but in some situations it is desirable to explicitly manage which
>>> ToggleGroup is used by
>>> Toggles<
>>> http://docs.oracle.com/javafx/2/api/javafx/scene/control/Toggle.html>
>>>
>>> ."
>>>
>>> Well, I tried to "explicitly manage" them, but I get :
>>> ...
>>> Caused by: java.lang.IllegalArgumentException: Duplicate toggles are not
>>> allow in a ToggleGroup.
>>> at
>>> javafx.scene.control.ToggleGroup$1.onProposedChange(ToggleGroup.java:63)
>>> at
>>>
>>> com.sun.javafx.collections.VetoableObservableList.add(VetoableObservableList.java:165)
>>> at
>>>
>>> com.sun.javafx.collections.ObservableListWrapper.add(ObservableListWrapper.java:144)
>>> at
>>> javafx.scene.control.RadioMenuItem$1.invalidated(RadioMenuItem.java:151)
>>> at
>>>
>>> javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:129)
>>> at
>>> javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:163)
>>> at
>>> javafx.scene.control.RadioMenuItem.setToggleGroup(RadioMenuItem.java:134)
>>> at javafx.scene.control.ToggleGroup$1.onChanged(ToggleGroup.java:87)
>>> at
>>>
>>> com.sun.javafx.collections.VetoableObservableList.callObservers(VetoableObservableList.java:83)
>>> at
>>>
>>> com.sun.javafx.collections.ObservableListWrapper.addAll(ObservableListWrapper.java:171)
>>> at
>>>
>>> com.sun.javafx.collections.VetoableObservableList.addAll(VetoableObservableList.java:108)
>>> at
>>>
>>> com.sun.javafx.collections.ObservableListWrapper.addAll(ObservableListWrapper.java:160)
>>> at
>>>
>>> com.sun.javafx.collections.ObservableListWrapper.addAll(ObservableListWrapper.java:309)
>>> at toggletest.ToggleTest.start(ToggleTest.java:34)
>>> ...
>>>
>>> This is just by doing:
>>>
>>> ToggleGroup toggleGroup = new ToggleGroup();
>>> RadioMenuItem [] radioButtons = new RadioMenuItem[] {
>>> new RadioMenuItem("One"),
>>> new RadioMenuItem("Two"),
>>> new RadioMenuItem("Three")
>>> };
>>>
>>> toggleGroup.getToggles().addAll(radioButtons);
>>>
>>>
>>> Bug?
>>>
>>> Scott
>>>
>>
>>
>
More information about the openjfx-dev
mailing list