wx
2008-09-09 18:11:19 UTC
I'd like to implement a menu with JMenu which has submenus. I'd like
to be able to click on an item or choose it with the keyboard with
enter or accelerator. This applies to both leaf menu items (without
submenus), but I'd also like to be able to choose JMenus (which have
submenus) and perform some action in that case. How to detect when a
JMenu is chosen? I tried adding an ActionListener, but that did not
work. I can implement mouse listener and key listener, but is there an
unified way to get "menu chosen" event, regardless of the method the
menu item has been chosen? I.e. is there something similar to
ItemListener, with the difference that the event should be fired when
the menu was actually chosen (e.g. mouse click, keyboard enter), not
only selected (e.g. mouse over, keyboard arrows)?
to be able to click on an item or choose it with the keyboard with
enter or accelerator. This applies to both leaf menu items (without
submenus), but I'd also like to be able to choose JMenus (which have
submenus) and perform some action in that case. How to detect when a
JMenu is chosen? I tried adding an ActionListener, but that did not
work. I can implement mouse listener and key listener, but is there an
unified way to get "menu chosen" event, regardless of the method the
menu item has been chosen? I.e. is there something similar to
ItemListener, with the difference that the event should be fired when
the menu was actually chosen (e.g. mouse click, keyboard enter), not
only selected (e.g. mouse over, keyboard arrows)?