| Author |
JScrollPane adding JPanels at the top and keeping current scroll view
|
John Jacobs
Greenhorn
Joined: Feb 27, 2011
Posts: 2
|
|
I have a JScrollPane that contains a vertical Box. I'm inserting new JPanel's at the top of Box. If I use the scrollbar to scroll down I'd like for the current view to remain where I scrolled down to. For example, if I have 50 panels in the box and use the scrollbar to view panel 20, I'd like the view to remain on box 20 even though other boxes are added on top. Additionally, if I use the scrollbar to scroll back up to the top I'd like the view to display new panels as they are added. Any idea how to do this?
BTW, it isn't necessary to use a JScrollPane or a Box. The example code is just to help explain what I am trying to do.
Example code:
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19214
|
|
Welcome to the Ranch!
I'll move this thread to our GUI forum.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Rob Camick
Ranch Hand
Joined: Jun 13, 2009
Posts: 1786
|
|
Cross posted: http://stackoverflow.com/questions/5132802/jscrollpane-adding-jpanels-at-the-top-and-keeping-current-scroll-view/5134255#5134255
Be Forthright When Cross Posting To Other Sites
|
 |
John Jacobs
Greenhorn
Joined: Feb 27, 2011
Posts: 2
|
|
Sorry, I forgot. Anyways, the folks at that site where able to provide the solution. Pretty obvious and simple in hindsight.
|
 |
 |
|
|
subject: JScrollPane adding JPanels at the top and keeping current scroll view
|
|
|