I would like to be able to add a menu to a desktop application that I have started to develop. I mean a classic application menu, which on Windows is displayed immediately below the title bar (with items like "File", "Edit", "View", etc.), while on MacOS it is displayed in the top bar common to all applications ("App menu"). Ideally each menu item could invoke an ActionListener, just like tapping a Button.
However, I have not found any information about this and I do not even know if it is possible at the moment. Thank you for your suggestions.
This is a feature we plan to add early on in the 8.0 release cycle as we already make some (minimal) use of it in our own apps. Right now the only option is to use the Swing APIs to add the menus using native interfaces.
You can get all the JFrame
instances (of which there can be only one) and add any menu to that. If you use the Mac JMenuBar
on a typical Codename One build then it will be on top by default since we set this implicitly through: System.setProperty("apple.laf.useScreenMenuBar", "true");
.
You can just add entries to menu bar.