File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Problem in Opening JPopupMenu Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Problem in Opening JPopupMenu" Watch "Problem in Opening JPopupMenu" New topic

Problem in Opening JPopupMenu

Murugesan Velayutham

Joined: Oct 29, 2004
Posts: 2

We are facing a problem in opening JPopupMenu in multiple browser windows. We have a parent window which has a JApplet. We have another window which is a child window of the parent. That also has a different applet.

When we right click on the applet which is available in the parent window, the popup menu shows up.
When we do the same on the child window, the popup shows up finely. Now when we select any menu item in the child window's popup, the focus goes to the parent window and then immediately comes back to the child window.

We are not overriding any focus lost event in the applets or handling any key events. We are using JDK 1.4.1 plugin to the browser.

I appreciate your suggestion/comments.

Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
I made up this test program and it does not exhibit the behavior you describe.
Murugesan Velayutham

Joined: Oct 29, 2004
Posts: 2
I will resate the problem described earlier.

We have an applet which is displayed in 2 browser instances (parent/child) windows. The 2 windows have different instances of the same applet.

Problem : When the user right clicks on the applet container, a popup menu is displayed. Keeping the popup menu display intact, when the user moves to the child window and right clicks on the applet container to display the popup menu, slight flickering happens which is to dispose the popup menu displayed in the first applet and then displays in the second applet.

In the mouseReleased() method in the applet we are creating a new instance of JPopupMenu adding the necessary menu items and then displaying it. We have made sure that the 2 browser windows are having 2 different instances of the applet.

Does this mean that the JVM always creates one instance of the popup menu ?? OR how to avoid this flickering problem ??

Further to the problem mentioned above :

1. The user right clicks on the first applet to display the popup menu.
2. Clicks on a menu item (Currently no event is fired when the menu is selected). The popup menu will be disposed after this operation.
3. The user then moves to the second applet and right clicks on the second applet to display the popup menu.
4. Now when the user presses the mouse button on the menu item, there is a focus shift from the second applet to the first applet. And when the mouse is released the focus comes back to the second applet.

Note : There is no actionlistener is added to the menu items.

Any one has any idea why this kind of behaviour is occurring in the applet and popup menu ??
Consider Paul's rocket mass heater.
subject: Problem in Opening JPopupMenu
It's not a secret anymore!