JMenuBar and JPopupMenu in JMEDesktop

I have successfully adapted JMEDesktop to show me a JMenuBar (new JMenuBar, add a few menu items, size the menubar, add add to desktopPane). This works fine, but when I click on a menu (e.g., "File"), the menu popup does not appear. I have made JPopupMenus to be heavyweight by default. On the other hand, I have successfully adapted JMESwingTest to incorporate a menu, – and there, everything worked out quite nice with making JPopups heavyweight. I have tried to bring those two classes together in a new test (say, JMEDesktopSwingTest), but it all was too heavy for me to figure out.



So please, advise. I need just menus (whatever: awt.MenuBar or JMenuBar) and popups to appear in JMEDesktop.



cheers Gabriel

Popup menus should work if they are lightweight. Heavyweight stuff cannot work in JMEDesktop.



Integrating JMEDesktop and Swing stuff around a jme canvas, will at least have a lot of issues, so I cannot recommend that. Most likely some of those issues are not solvable, as JMEDesktop needs custom setup of e.g. popup manager which is not compatible with standard swing applications.

I've tried to use lightweight popups, i.e.



JPopupMenu m = new JPopupMenu();

JMenu f = new JMenu("File");

m.add(f);

f.add(new JMenuItem("Foo"));

m.setLocation(100,100);

m.setSize(100,100);

desktopPane.add(m);



but it did not show up. has someone ever managed to get one on screen ?



cheers gabriel



P.S.: I am strongly considering coding a popup menu myself now, since I know that panels work, and buttons work; but that would be really only if there is no other solution.

irrisor said:
Popup menus should work if they are lightweight.


Aren't popup menus subject to the well known popup problem introduced in java 6? Or is that fixed now?
gabrielwurzer said:

but it did not show up. has someone ever managed to get one on screen ?

yes, TestJMEDesktop shows a popup on some button.

verified: popups work only in JDK1.5;

JComboBox contents won't show in JDK1.6, as well as PopupMenus contained in JMenus. As soon as I tried the following code with JDK1.5, everything was as expected:



Modified TestJMEDesktop—



protected void createSwingStuff() {



        JMenuBar m = new JMenuBar();     

        m.setLocation(0,0);

        m.setSize(desktopPane.getWidth(), 30);

        JMenu test = new JMenu("test");

        m.add(test);

        test.add(new JMenuItem("BLAH"));       

        desktopPane.add(m);

}



thanks for pointing me into the right direction, irrisor and hevee.






Yeah, it seems that the combo box in the test doesn't work here in 1.6 either.  Does anyone know if there is a fix for this?  I would like to be able to use combo boxes.

691175002 said:

Does anyone know if there is a fix for this?

Read the thread I linked above. It's the only solution that is currently available AFAIK.

As you can find in the issue linked from the thread hevee mentioned, the bug is apparently fixed in jdk1.6u4(b03) - but I did not test that

irrisor said:

As you can find in the issue linked from the thread hevee mentioned, the bug is apparently fixed in jdk1.6u4(b03) - but I did not test that


I've just installed the jdk-6u10-b07 and this bug is indeed fixed. :)