Problem while scrolling a JScrollPane - Threads

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
задан jjnguy 27 August 2010 в 18:05
поделиться

2 ответа

Вы можете попытаться создать новый поток и вызвать фиктивный метод invokeAndWait для этого потока. После этого все ожидающие события должны быть завершены, и ваш код прокрутки должен работать.

1
ответ дан 2 September 2019 в 21:45
поделиться

Почему вы делаете это с другой темой? Не могли бы вы вместо этого использовать

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

That или что-то подобное, чтобы делать то, что вам нужно.

1
ответ дан 2 September 2019 в 21:45
поделиться
Другие вопросы по тегам:

Похожие вопросы: