Help | Site Map
Connecting Tech Pros Worldwide
Reply
 
LinkBack Thread Tools
  #1  
Old October 4th, 2008, 03:44 PM
TheMan1's Avatar
Newbie
 
Join Date: Mar 2008
Posts: 19
Default 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.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?
Reply
  #2  
Old October 4th, 2008, 05:01 PM
Moderator
 
Join Date: Mar 2007
Location: Voorschoten, the Netherlands
Age: 52
Posts: 8,493
Default

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
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles