Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Scrolling a JScrollPane inside a JPopupMenu - Race condition?

843807Aug 17 2010 — edited Aug 18 2010
Hello,

I have a problem that I am unable to solve.

I have a JPanel that gets displayed using JPopupMenu. It shows some options for the user to choose from. This JPanel has a JScrollPane which contains the options that are custom JPanel objects each. These options are added to the scroll pane on runtime.

But the problem is, when this panel gets displayed, the scroll pane is scrolled to the middle of the contents automatically. I want it to show the topmost item first. I have tried all of the options for scrolling a JScrollPane, but it simply ignores every command I use.

I think there is some kind of race condition when I try to scroll it upwards. I think it tries to scroll the scroll pane before it is displayed.

I have no idea how to fix this. What do I need to do?

Please help,

Emre

Edited by: emre.c on Aug 17, 2010 5:45 AM

Changed the topic.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 15 2010
Added on Aug 17 2010
7 comments
644 views