πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #7876

Re: FlowLayout and JScrollPane

#7876
From: John McGrath TeamB
Date: Tue, 05 Dec 2000 00:00
39 lines
2107 bytes
On Sun, 3 Dec 2000 15:22:19 +0100, "Thomas GοΏ½lden \(p\)" 
<Thomas.Guelden@t-online.de> wrote:

> I try to develop an image browser, where thumbnails of images
> are put in rows.  So to use the FlowLayout as the layout for my
> panel seems to be the right choice, becau=F#@Y'8uts components
> in a new row when one row is full, depending on the width of
> the panel. However, when the rows extend the height of my panel
> I would like to show a scrollbar on the right of the panel.

This is a problem I have dealt with on a number of occasions.  I have 
some example code at the office that I can post for you, but I do not 
have it right now.  I will try to get to it tomorrow.  Actually, I have 
a program that displays image thumbnails exactly as you describe, but 
alas, I cannot post that.

Question: Are you using an AWT ScrollPane or a Swing JScrollPane?

Here is a brief description of the problem:

When asked for the preferred size of a container, a FlowLayout will 
return a size that assumes its children will be laid out in a single 
row.  This is because there is no mechanism to tell the child the 
maximum width available.

When a ScrollPane or the JViewport of a JScrollPane is laid out, it 
gives the child component any size it desires.  After all, that is what 
the scroller is supposed to do.  So the scroller gives the child 
component exactly the size it asks for, and the child is laid out in a 
single row.

-- 
Regards,

John McGrath [TeamB]

---------------------------------------------------
Before sending me e-mail, please read:
    http://www.JPMcGrath.net/newsgroups/e-mail.html
Technical Details
Message-ID: <MPG.149685b74a9e9bc4989d95@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <90dkq2$fr4@bornews.inprise.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 111d45,282a839afa7c07f
X-Google-Attributes: gid111d45,public
From: John McGrath  [TeamB] <ng-b@JPMcGrath.net>
Subject: Re: FlowLayout and JScrollPane
Date: 2000/12/05
Message-ID: <MPG.149685b74a9e9bc4989d95@forums.borland.com>
X-Deja-AN: 701306331
References: <90dkq2$fr4@bornews.inprise.com>
Organization: Another Netscape Collabra Server User
Newsgroups: borland.public.jbuilder.java.swing