wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Is there any tool to find the location of a componenet in the frame in Swing? 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 "Is there any tool to find the location of a componenet in the frame in Swing?" Watch "Is there any tool to find the location of a componenet in the frame in Swing?" New topic
Author

Is there any tool to find the location of a componenet in the frame in Swing?

Thennam Pandian
Ranch Hand

Joined: Oct 11, 2005
Posts: 163
Hi,

We have tool to locate each component in a web page. Also we can change the location of component in run-time.
I need a similar tool to locate each component in a frame.

It will be very useful to locate the component, if it not visible in frame.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10174
    
    8

I am not aware of any such tool. I doubt if its more than a few lines of code.

From the top of my head, in pseudo code
1) Get all child components inside a Container(hint)
2) Get the bounds(hint) of each child
3) Use recursion


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38075
    
  22
Don't you get the components as an array if you use the right method, so you can recursively traverse that array?
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Or -
- get the component's location on screen
- get the window ancestor for the component (SwingUtilities method)
- get the window's location on screen
- do the math

luck, db
There are no new questions, but there may be new answers.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is there any tool to find the location of a componenet in the frame in Swing?
 
Similar Threads
Detecting Startup Folder on Windows
Frames??
how to change the image pixel color on particular location
Is there a way to find out color of whatever's behind my frame?
Saving panel content?