Maybe i’ve overlooked something obvious, but i’ve been trying to work out the actual screen position of a nifty element to super impose some gui elements on top (like map markers on a map).
This works fine when the position is known (like the upper left corner), but when it’s relative to several parents, it’s trickier.
I’ve tried recursion (getParent()) to do this, but i don’t get consistent results.
Is there a better way?
[java]Element e = …;
int x = e.getX();
int y = e.getY();
int width = e.getWidth();
int height = e.getHeight();[/java]
I must be something missing or I’m not understanding your question correctly since these methods are pretty obvious, right?
These methods will give you the actual absolut screen coordinates in pixels of the element in question independenly of their parent relationship.
But maybe I’m missing something as well?
No, i think it’s i who missed something.
Thanks for the clarification.
It was too obvious.
No, what i think happened was:
I tried it, but didn’t get the expected result (due to somethings else, like not translating the gui position right) and went on to find another solution (ie recursion). Then i fixed the other problem, but kept my “bad” solution.
Seems to be working fine now