Article View: borland.public.jbuilder.java.swing
Article #12660Re: ViewportLayout bug? (was Re: JList size in a JScrollPane?)
From: Paul Furbacher
Date: Wed, 18 Nov 1998 00:00
Date: Wed, 18 Nov 1998 00:00
38 lines
2290 bytes
2290 bytes
Dave Howorth wrote: > Once I got rid of the sizing problem, I fixed this as well. My code looks > like this: > > jList.setModel(model); > jScrollPane.getViewport().invalidate(); > > Heaven knows why it works. What I'd really like to see is a definitive, > coherent explanation of these incantations :-) ... > Though you'd think it was pretty much a no-brainer that the layout would > need to be redone after you change the entire list contents. There's no way for the JList to know that it is contained in anything. Hence, since you set up the containment hierarchy (inside a JScrollpane), you have to handle the telling the containers that they are invalid and need to be layed out again (and repainted). If they were to assume a JScrollPane/JViewport container, and do a relayout in JList.setModel(), what would happen if someone assigned a parent that doesn't behave as a JScrollPane might to such a request? I would guess that the Swing team is thinking along the lines of greatest flexibility and fewest assumptions in this regard. Just a guess. The simplest rule to remember with Swing components is to invoke "validate()" and/or "invalidate()" when changing properties of a component. > But I suspect we'll see a slew of JDK 1.2 books around Xmas :-), > so I'm not rushing to the shops just yet, ... I just sit in Barnes & Noble, and read like crazy. You'll find this kind of stuff in just about any in-depth Swing book. Paul Furbacher
Technical Details
Message-ID:
<3652571B.E50FC54D@bilbo.bio.purdue.edu>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<727hon$ov14@forums.borland.com> <72fu3o$d5n28@forums.borland.com> <364D2037.7227@flash.net> <72ni1c$ob11@forums.borland.com> <364FBE5E.493DEE04@bilbo.bio.purdue.edu> <72qq5l$s946@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,1177ab7a6295220d X-Google-Attributes: gid111d45,public From: Paul Furbacher <pf@bilbo.bio.purdue.edu> Subject: Re: ViewportLayout bug? (was Re: JList size in a JScrollPane?) Date: 1998/11/18 Message-ID: <3652571B.E50FC54D@bilbo.bio.purdue.edu> X-Deja-AN: 413035245 Content-Transfer-Encoding: 7bit References: <727hon$ov14@forums.borland.com> <72fu3o$d5n28@forums.borland.com> <364D2037.7227@flash.net> <72ni1c$ob11@forums.borland.com> <364FBE5E.493DEE04@bilbo.bio.purdue.edu> <72qq5l$s946@forums.borland.com> Content-Type: text/plain; charset=us-ascii Organization: Biological Sciences, Purdue Univ. Mime-Version: 1.0 Reply-To: pf@bilbo.bio.purdue.edu Newsgroups: borland.public.jbuilder.java.swing