Simple: Changing scroller size on JScrollPane?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • TheMan1
    New Member
    • Mar 2008
    • 19

    #1

    Simple: Changing scroller size on JScrollPane?

    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.get HorizontalScrol lbar().setMaxim um(), 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
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    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

    Comment

    Working...