Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » cannot set Mac OS menus from eclipse plugin
cannot set Mac OS menus from eclipse plugin [message #254986] Wed, 30 April 2008 10:47 Go to next message
Eclipse UserFriend
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.
Re: cannot set Mac OS menus from eclipse plugin [message #254998 is a reply to message #254986] Wed, 30 April 2008 12:32 Go to previous messageGo to next message
Achim Loerke is currently offline Achim LoerkeFriend
Messages: 376
Registered: July 2009
Location: Braunschweig, Germany
Senior Member

On Wed, 30 Apr 2008 10:47:48 +0000 (UTC), gabriel_erzse@yahoo.com
(Gabriel Erzse) wrote:

>I have an eclipse plugin, which has an action that opens up a simple Swing
>form.

Eclipse uses SWT as its GUI toolkit. You can create a JFrame, but
there is no event dispatcher running, so no redraws are performed.

To use Swing within Eclipse you must use a supporting framework, for
instance Albireo.


Achim
--
Achim Lörke

Eclipse-Stammtisch in the Braunschweig, Germany area:
http://www.bredex.de/de/career/eclipse.html


Achim Lörke

Re: cannot set Mac OS menus from eclipse plugin [message #255021 is a reply to message #254998] Wed, 30 April 2008 14:19 Go to previous message
Eclipse UserFriend
Originally posted by: gabriel_erzse.yahoo.com

True. If I rewrite the frame in SWT instead of Swing, the Mac OS menubar
is updated correctly and the menu is displayed.

Thank you,
Gabi.
Previous Topic:Plug-in static resource problem
Next Topic:begin typing anywhere in editor
Goto Forum:
  


Current Time: Fri Dec 27 12:39:29 GMT 2024

Powered by FUDForum. Page generated in 0.07903 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top