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 / General / January 2006

Tip: Looking for answers? Try searching our database.

recalculate layout

Thread view: 
Tomba - 05 Jan 2006 11:38 GMT
Hi,

during execution I'm changing the preferred size of some components.
These are contained in a JPanel with a borderlayout.
However when updating the layouter does not change the size of the
components with the changed preferred sizes.

When I resize the window with the mouse then everything gets painted ok,
but how can I order the panel to recalculate and repaint everything
without having to resize the panel?

Thanks
Andrew Thompson - 05 Jan 2006 11:59 GMT
> during execution I'm changing the preferred size of some components.

Why?

> These are contained in a JPanel with a borderlayout.
> However when updating the layouter ...

Which involves what exactly?  What Java code do you
use when 'updating the layouter'?

>...does not change the size of the
> components with the changed preferred sizes.

> ...how can I order the panel to recalculate and repaint everything
> without having to resize the panel?

Tried pack()/validate()?

Signature

Andrew Thompson
physci, javasaver, 1point1c, lensescapes - athompson.info/andrew

Tomba - 05 Jan 2006 12:30 GMT
>> during execution I'm changing the preferred size of some components.
>
> Why?

Just because I have a multiline label and when the text changes, so may
its preferred height to display the lines (at most 2 or 3).

>> These are contained in a JPanel with a borderlayout.
>> However when updating the layouter ...
>
> Which involves what exactly?  What Java code do you
> use when 'updating the layouter'?

I want the borderlayout to update the sizes of SOUTH as I changed the
preferred size of it.

>> ...does not change the size of the components with the changed
>> preferred sizes.
[quoted text clipped - 3 lines]
>
> Tried pack()/validate()?

A JPanel does not support pack(), and I've tried invalidate() without
succes.
Andrew Thompson - 05 Jan 2006 13:09 GMT
>>> during execution I'm changing the preferred size of some components.
>>
>> Why?
>
> Just because I have a multiline label

Label or JLabel?

>..and when the text changes, so may
> its preferred height to display the lines (at most 2 or 3).

consider placing the label inside a JScrollPane, or putting the
message in a J/Dialog

>>> These are contained in a JPanel with a borderlayout.
>>> However when updating the layouter ...
[quoted text clipped - 3 lines]
>
> I want ..

I did not ask what you want!  I asked what exact
code you typed to attempt to achieve that.

>..the borderlayout to update the sizes of SOUTH as I changed the
> preferred size of it.

Most UI components can determine their own preferred size
without you setting it specifically.  In fact, that you
need to is generally a sign of trouble.

>>> ...how can I order the panel to recalculate and repaint everything
>>> without having to resize the panel?
>>
>> Tried pack()/validate()?
..
> A JPanel does not support pack(),

Oh yeah, right.  Try packing the frame.

>.. and I've tried invalidate()

'invalidate()' is not 'validate()'

> ..without succes.

If you do not discover the answer based on these tips, I
suggest you post a short compilable example of code that fails.
<http://mindprod.com/jgloss/sscce.html>

Oh, BTW - the best group for such matters is
'comp.lang.java.gui' .

Signature

Andrew Thompson
physci, javasaver, 1point1c, lensescapes - athompson.info/andrew

Chris Smith - 05 Jan 2006 17:04 GMT
> >> Tried pack()/validate()?
> ..
[quoted text clipped - 7 lines]
>
>  > ..without succes.

In Swing, use revalidate().  In AWT, invalidate() and then validate()
the appropriate container.

Signature

www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation



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



©2008 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.