views:

58

answers:

2

Hello,

The situation is like this:

Upon clicking on a menu item, some components are added to a JScrollPane, the components are resized, then setVisible method of JScrollPane is called. Resizing of components are out of my control. (TextAreas getting resized according to their contents. Caret updates are disabled.)

I want to scroll the JScrollPane to the bottom. Using invokeLater and a Runnable that scrolls the list down by using getMaximumValue method does not seem to work in this case (while it normally does for other parts of the program).

Is there a way to make the Runnable thread get notified after making sure that everything related to the operations above are done?

Thanks in advance.

+1  A: 

Why are you doing that with another Thread? Could you instead use

JViewPort view = new JViewPort();
view.setPoint(new Point(0, heightOfContents));
scrollPane.setViewPort(view);

That, or something similar should do what you need.

jjnguy
Sadly, it does not work. It just ignores the command like the others do.
Emre
@Emre, hmm. Sorry, but I can't think of any other solutions.
jjnguy
+1  A: 

You colud try to create new thread and call dummy invokeAndWait on that thread. After that, all pending events should be finished and your scroll code should work.

aco
Could you possibly post a small code snippet, please?
Emre