Hello,
i have a JMenu, with JCheckBoxMenuItem in it.
When the user clicks on a JCheckBoxMenuItem, i open a JDialog, and if the user select "Cancel", i want to undo the checking of the menu item.
If it's possible, i would like to prevent the changes of the menu item state.
If it's not possible, i will subclass JCheckBoxMenuItem, and add saveState() / restoreState().
So is it possible to prevent the automatic change?
TIA
Andrey Kuznetsov - 09 Mar 2005 20:47 GMT
> When the user clicks on a JCheckBoxMenuItem, i open a JDialog, and if the
> user select "Cancel", i want to undo the checking of the menu item.
since JCheckBoxMenuItem is subclass of AbstractButton you can use
JCheckBoxMenuItem#setSelected(false);

Signature
Andrey Kuznetsov
http://uio.dev.java.net Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities
Mr Smith - 10 Mar 2005 09:18 GMT
> > When the user clicks on a JCheckBoxMenuItem, i open a JDialog, and if the
> > user select "Cancel", i want to undo the checking of the menu item.
> >
> since JCheckBoxMenuItem is subclass of AbstractButton you can use
> JCheckBoxMenuItem#setSelected(false);
No because if the item was already the one selected, i must not unselect it.
i will add a saveSelectedState()/restoreSelectedState()
Mr Smith - 10 Mar 2005 16:22 GMT
> i will add a saveSelectedState()/restoreSelectedState()
for those who are interested, i didn't manage to make it work, i had to do a special JMenu which only allow 1 JMenuItem selected at a time (i don't select through "item.setSelected()" anymore but with "menu.SetSelectedItem(item)".
Andrey Kuznetsov - 10 Mar 2005 17:32 GMT
>> i will add a saveSelectedState()/restoreSelectedState()
>
> for those who are interested, i didn't manage to make it work, i had to do
> a special JMenu which only allow 1 JMenuItem selected at a time (i don't
> select through "item.setSelected()" anymore but with
> "menu.SetSelectedItem(item)".
why don't you post your code, may be some one can help you?

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