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.
Вы можете попытаться создать новый поток и вызвать фиктивный метод invokeAndWait для этого потока. После этого все ожидающие события должны быть завершены, и ваш код прокрутки должен работать.
Почему вы делаете это с другой темой
? Не могли бы вы вместо этого использовать
JViewPort view = new JViewPort();
view.setPoint(new Point(0, heightOfContents));
scrollPane.setViewPort(view);
That или что-то подобное, чтобы делать то, что вам нужно.