I am using Action objects when building my JCheckBoxMenuItem and
JToggleButton items in the menubar and toolbar.
I assumed this would keep the two in sync just like happens with the
"enabled" property, but it seems I somehow have to manage the
checked/toggled state myself. Is this true? If so, how is it typically done?
Thanks in advance,
Casper
Vova Reznik - 22 Nov 2005 17:10 GMT
> I am using Action objects when building my JCheckBoxMenuItem and
> JToggleButton items in the menubar and toolbar.
[quoted text clipped - 3 lines]
> checked/toggled state myself. Is this true? If so, how is it typically
> done?
Actions has nothing to do with state (select/deselect).
To keep both components in sync you may try to share ButtonModel.
> Thanks in advance,
> Casper
jonck@vanderkogel.net - 22 Nov 2005 17:26 GMT
> I assumed this would keep the two in sync just like happens with
> the "enabled" property, but it seems I somehow have to manage
> the checked/toggled state myself. Is this true? If so, how is it
> typically done?
Your Action does not maintain the state of your checkbox, togglebutton,
etc... It merely dictates what should happen if the Action is
triggered. If you want the components to be notified of their
respective changes, you'll have to set them up as listeners of each
other.
Andrey Kuznetsov - 22 Nov 2005 18:13 GMT
>I am using Action objects when building my JCheckBoxMenuItem and
>JToggleButton items in the menubar and toolbar.
[quoted text clipped - 3 lines]
> checked/toggled state myself. Is this true? If so, how is it typically
> done?
see http://jgui.imagero.com/examples/SelectableAction/

Signature
Andrey Kuznetsov
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities