cannot set Mac OS menus from eclipse plugin [message #254986] |
Wed, 30 April 2008 10:47 |
Eclipse User |
|
|
|
Originally posted by: gabriel_erzse.yahoo.com
I have an eclipse plugin, which has an action that opens up a simple Swing
form. The Swing form has a menubar, which is configured to show in the Mac
OS system menubar (by setting the "apple.laf.useScreenMenuBar" property).
However, when the frame appears on the screen, its menubar is not
displayed (the Mac OS system menubar is cleared).
The action class looks like this:
public class MyActionDelegate implements IWorkbenchWindowActionDelegate {
MyFrameWithMenubar child;
public void dispose() {
child.dispose();
}
public void init(IWorkbenchWindow window) {
System.setProperty("apple.laf.useScreenMenuBar", "true");
child = new MyFrameWithMenubar();
child.pack();
}
public void run(IAction action) {
child.setVisible(true);
}
public void selectionChanged(IAction action, ISelection selection) {
}
}
And the Swing frame looks like this:
public class MyFrameWithMenubar extends JFrame {
private static final long serialVersionUID = 2644194413142912399L;
public MyFrameWithMenubar()
{
super("Frame with menubar");
JMenuBar mb = new JMenuBar();
JMenu actions = mb.add(new JMenu("Actions"));
actions.add(new JMenuItem("Do this"));
actions.add(new JMenuItem("Do that"));
JMenu help = mb.add(new JMenu("Help"));
help.add(new JMenuItem("Show help"));
setJMenuBar(mb);
setPreferredSize(new Dimension(640, 480));
setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
}
}
If I display the same frame from a regular Java project (not a plugin
project), then the menubar is installed and displayed correctly. It looks
like Eclipse is restricting access to the system menubar, or something
like this.
Does anyone have any idea how to fix this problem, or at least in what
direction to search for a solution to it?
Thank you,
Gabi.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06882 seconds