• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Thennam Pandian
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11196
15
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Campbell Ritchie
Sheriff
Pie
Posts: 50277
80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5148
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic