Search code examples
javaswingjava-3djpopupmenu

JPopupMenu in Java3d applet does not receive mouse or keyboard input


I have a a Java application that uses Java3D and JPopupMenus filled with JMenuItems. Everything works fine when it runs as a regular application-- the JPopupMenus and everything else behave as expected. However, when I make an applet out of the application, the JPopupMenu that pops up entirely over the Canvas3D does not act as expected. The JPopupMenu behaves as follows:

  1. The menu items do not highlight as the mouse moves over them
  2. The arrow keys cannot be used to move through the menu items
  3. Clicking on a top-level JMenuItem completes the action and highlights the item, but it does not dispose of the JPopupMenu as it does in the regular application
  4. Clicking on a top-level JMenuItem that contatins a submenu does nothing
  5. Clicking outside of the JPopupMenu does not dispose of the JPopupMenu as it does in the regular application
  6. With the JPopupMenu displayed, opening a JPopupMenu on top of the swing portion of my program enables regular and expected behavior of the JPopupMenu over the Canvas3D, but point 5 still applies

Some more information:

  • The JPopupMenu is displayed with JPopupMenu.show() in relation to the JPanel holding the Canvas3D
  • I am calling JPopupMenu.setDefaultLightWeightPopupEnabled(false) before the creation of any JPopupMenus, but this line doesn't seem to make a difference.
  • I thought that this might have been a focus issue, but JPopupMenu.requestFocusInWindow() doesn't work

So my question is: what is causing the behavior to be different between the application and the applet, and how can I make the JPopupMenu in the applet function as it does in the application?


Solution

  • You have to change lightweight JPopup to heavyweight hard to talk something else without posting your SSCCE