Alright, I know HOW to do but It's doing something weird.
I am trying to get the correct X Y coords for a JMenu
to appear. I've found a way but it's only a hack. All the right-clicking takes place on the JList
, for now until I add character panel, so let's say you right-click near the top-left. You expect the Y coord to be around 40~ pixels and the Y coord to be around 100~ pixels right? Because you're clicking on the near left where the JList
is. Wrong. The x y coords count from the top left of the JList
when I want it to count from the top left of the WHOLE application. :S
So, what did I do? Since the Y coord is correct, I added 512 pixels to the X coord so it's always in the JList. Like so:
int newMouseX = 512+e.getX();
popup.show(tileOffline.this, newMouseX, e.getY()); // show item at mouse
However, as you can tell I will not be right-clicking in the JList
forever.
How can I make it so I get the exact X Y coords of the mouse from the WHOLE applet?
Here's a pic to describe the situation WITHOUT the 512 hack: