wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes When should the getLocation() be called Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "When should the getLocation() be called" Watch "When should the getLocation() be called" New topic
Author

When should the getLocation() be called

Alec Lee
Ranch Hand

Joined: Jan 28, 2004
Posts: 569
In the javadoc for java.awt.Component.getLocation(), there is such a description:

Due to the asynchronous nature of native event handling, this method can return outdated values (for instance, after several calls of setLocation() in rapid succession). For this reason, the recommended method of obtaining a component's position is within java.awt.event.ComponentListener.componentMoved(), which is called after the operating system has finished moving the component.


But I don't understand what this statement means and if the call isn't reliable at all why it is there? If I dont want the trouble of using a listener, how should we use getLocation() to retreive the component's location?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: When should the getLocation() be called
 
Similar Threads
building BufferedImage not in EDT - good or bad?
Finding X Y location of button
Valuechangelistener f:selectitems
x,y of buttons ?
multiple 'chaining' of dot operators