Goal: to have top level menu as per native application (e.g. Mac OSX menu or
Windows main window menu).
I could not find a way (using pivot components) in tutorials, mail list, google.
Is there a better way to do this than by directly using Java AWT Frame and
menus?
e.g.
public static void main(String[] args) {
System.setProperty("apple.laf.useScreenMenuBar", "true");
DesktopApplicationContext.main(MyMainClass.class, args);
java.awt.Frame[] activeframes = java.awt.Frame.getFrames();
for (java.awt.Frame f : activeframes) {
if (f.isVisible()) {
f.setMenuBar(createMenuBar());
}
}
}
public static java.awt.MenuBar createMenuBar() {
java.awt.MenuBar menuBar = new java.awt.MenuBar();
menuBar.add(createFileMenu());
return menuBar;
}
public static java.awt.Menu createFileMenu() {
java.awt.Menu m = new java.awt.Menu("File");
MenuItem mi = new MenuItem( "Open", new MenuShortcut( KeyEvent.VK_O ));
mi.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
System.out.println("****** OPEN ******");
}
});
m.add(mi);
return m;
}