Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / December 2003

Tip: Looking for answers? Try searching our database.

Actualization of JScrollPane  and ViewPort (newbie)

Thread view: 
Sergio - 11 Dec 2003 01:45 GMT
Hi all,
I've searched for a solution for a very simple problem but, so far, I
haven't been able to find it, so here it goes the problem:

I created a JComponent-derived object, called Graph, which basically
draws a graph in its paint(Graphics g) method.

I show this Graph object within a JScrollPane, which is in a JFrame
together with other controls. One of them, a JSlide, controls the size
of the Graph object (a zoom).

Almost everything works well: when sliding the JSlider its
ChangeListener calls a method in the Graph to change its PreferredSize
and calls repaint(). The Graph works as expected in response to the JSlider.
However, the JScrollPane and its viewport do not get affected by the
change in size of the Graph object until I resize the whole JFrame, thus
I cannot use the JScrollPane bars to navigate through the whole Graph
unless I resize the JFrame (which obviously it's not the desired
behaviour). When reducing the Graph the viewport does not get reduced
either, so I get a huge ScrollBar for a tiny Graph...

I have tryed calling repaint() over all the elements (JFrame,
JScrollPane, its viewport), and revalidate() over them, but humbly I
have to say I don't know how to solve it....

thanks in advance for any suggestion.

Sergio
A. Bolmarcich - 11 Dec 2003 04:19 GMT
[snip]
> I show this Graph object within a JScrollPane, which is in a JFrame
> together with other controls. One of them, a JSlide, controls the size
[quoted text clipped - 5 lines]
> However, the JScrollPane and its viewport do not get affected by the
> change in size of the Graph object until I resize the whole JFrame, thus
[snip]
After doing something that affects the PreferredSize of a Graph object,
invoke revalidate() on the Graph object.  Do not invoke repaint().
Sergio - 11 Dec 2003 17:54 GMT
Thanks A. Bolmarich,
as you probably already knew, it worked.
Sergio

> [snip]
> After doing something that affects the PreferredSize of a Graph object,
> invoke revalidate() on the Graph object.  Do not invoke repaint().
hiwa - 11 Dec 2003 10:02 GMT
> Hi all,
> I've searched for a solution for a very simple problem but, so far, I
[quoted text clipped - 24 lines]
>
> Sergio
It is no wonder, neither a problem. Your JSlide control does nothing
for the JScrollPane so it stays as is. Quite natural.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.