Grid Layout and component locations
Can any one tell me if it is possible to get the location of a Jlabel in a gridLayout using getLocation().
I have 12 labels in each 12 consecutive grids , one below the other .
This cycle continues till the input is exhausted. There is no user interaction at all. Once the program begins to run , it keeps writing to these grids .
Now I want to find out the location of each Jlabel . The program always returns x = 0, y = 0.
Why is this happening.
Suggestions for solution pls ?
RC
[527 byte] By [
cratnama] at [2007-11-27 10:58:33]

# 2
Ok. Thank you.
The reason I wanted the location is to be able to use scrollRectToVisible( new Rectangle ) method in order to make my panel scroll as they keep adding to the frame.
Right now my panel doesn't scroll. I want it to scroll. How to make it possible?
RC
# 3
You add the component to the panel, then you revalidate the panel. Now the component should have a valid location. Then try the scrollRectToVisible(...).
Note I find scrollRectToVisible() doesn't always work. If this is the case then you can try:
scrollPane.getViewport().setViewPosition(...);
# 4
Thanq.
I got it done by using getHeight() and then using this as the offset to increase the y-coordinate keeping the other three parameters in scrollRectToVisible( .... ) method.
But I have 2 new problems now.
1.I'm able to scroll very well .. But it tooooooo fast that before i could read the lines it is gone.. I have to time them, how?
2. Also, the scrolling stops once the main exceution completes. I mean, the panel scrolling is not synchronous with the main program execution. What should I do?