Connecting Tech Pros Worldwide Help | Site Map

Simple: Changing scroller size on JScrollPane?

TheMan1's Avatar
Newbie
 
Join Date: Mar 2008
Posts: 19
#1: Oct 4 '08
Hi guys. I have a mouse event on my frame that enlarges the size of a JPanel that in on a JScrollPane. When the JPanel's size changes, the JScrollPane's scrollbars don't "refresh" ie. their max values don't get bigger, so you can't scroll to see rest of the entire bigger JPanel anymore.

Any ideas? I'm not asking to change the physical size of the scrollbars, I want to change the max values (at least that's what I think you'd call it) of the scrollbars, so you can scroll more.

Thanks.

I've tried using JScrollPane.getHorizontalScrollbar().setMaximum(), and setting it to the new width value of the JPanel after is has been enlarged, but that doesn't work... Am I missing a refresh call or something?
JosAH's Avatar
Expert
 
Join Date: Mar 2007
Posts: 10,611
#2: Oct 4 '08

re: Simple: Changing scroller size on JScrollPane?


A JScrollPane just manages a JViewport and that view port doesn't psychically
know that its view has changed, you have to tell it that. The setView() method
tells it to change its view and your JScrollPane gives you access to its view
port. Do the simple math and update your components when you've resized
your JPanel.

kind regards,

Jos
Reply