I have a JPopupMenu object. Its behavior depends on its coordinates.
How can I get its position relatively to its parent container?
I have a JPopupMenu object. Its behavior depends on its coordinates. How can I
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In your
MouseListener‘s method (mouseReleased etc.) you should receive aMouseEventobject containing the current position. If you don’t want to use those values you can try using theComponent#getLocationmethod, otherwise theComponent#getLocationOnScreenbut it returns the absolute position, then you need to calculate the relative one.