Scrolling a JScrollPane inside a JPopupMenu - Race condition?
843807Aug 17 2010 — edited Aug 18 2010Hello,
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.