Re: JPopupMenu position changing



Martin Buerger wrote:

> ...
> frame.getX() + mouseevent.getX(), frame.getY() + mouseevent.getY()
> ...

Coordinates in the MouseEvent are relative to component receiving the event.
If coordinates are required to be converted between coordinate spaces, then
SwingUtilities.convertX() -methods can be used.

However, best fix would be just to use component receiving the mouseevent as
"invoker" for JPopup.show().

The fact that it seemed to "work" for uppper pane, is just because it's
origin happened to be at (0 0). If there would have been e.g. menubar
visible in JFrame, then popup location would have been failing also for it.

--
KI -- http://kari.world.dy.fi
.



Relevant Pages

  • Re: JPopupMenu position changing
    ... > Coordinates in the MouseEvent are relative to component receiving the ... Martin ... Prev by Date: ...
    (comp.lang.java.gui)
  • Re: JPopupMenu position changing
    ... best fix would be just to use component receiving the mouseevent ... I'm not sure if I understand you right: I have to receive the mouseevent via ... Prev by Date: ...
    (comp.lang.java.gui)