Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ScrollPane redraw question.

Posted on 1999-07-28
5
Medium Priority
?
251 Views
Last Modified: 2012-08-14
Hello!

I have panel added to scrollPane (with AS_NEEDED policy).

When I change panel's size (panel.setSize(w,h)) how should I redraw the scrollPane in order to enable scrolling for new panel size?

scrollPane.repaint() doesn't work. Do I miss smth?

Thank you in advance.
0
Comment
Question by:levg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 1

Expert Comment

by:masato
ID: 1247261
What did you add to the ScrollPane? Canvas?

ScrollPane panel = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);
panel.add(???????);
panel.setSize(w, h);

0
 

Author Comment

by:levg
ID: 1247262
ScrollPane scrollPane = new ScrollPane(ScrollPane.SCROLLBARS_AS_NEEDED);
Panel panel = new Panel();
panel.setSize(w,h);
scrollPane.add(panel);
It works.

Later in the program:
panel.setSize(newW,newH);
scrolls don't change!
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 1247263
panel.invalidate();
scrollPane.validate();
scrollPane.doLayout();

but all of them will set the size of the panel according to it's preferred size, so you should return correct preferredSize and not call setSize() directly
0
 

Author Comment

by:levg
ID: 1247264
It seems to work. Thanks. Grab your points.
0
 
LVL 16

Accepted Solution

by:
heyhey_ earned 200 total points
ID: 1247265
Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question