Article View: borland.public.jbuilder.java.swing
Article #12769ViewportLayout bug? (was Re: JList size in a JScrollPane?)
From: Dave Howorth
Date: Sun, 15 Nov 1998 00:00
Date: Sun, 15 Nov 1998 00:00
72 lines
3343 bytes
3343 bytes
Ross M. Dukeshier wrote ...
>Dave Howorth wrote:
>> >(1) When I make the dialog taller (as a user, dragging it at runtime),
the
>> >list [I assume] expands, adding white space after the end of the list.
This
>> >is fine. But when I then make the dialog box slightly shorter, a scroll
bar
>> >is added and I can scroll to a completely blank area. What should
happen,
>> >IMHO, is for the JList to remove the blank space and just become
'naturally'
>> >shorter, still with no scroll bar. What am I missing?
<snip>
>If that didn't help, it sounds like it may be adjusting the preferred
>size of the list differently depending on whether you're increasing or
>decreasing the size of the scrollpane. I'd add some code to print out
>the three sizes of both components in the execution log when you click
>on a button on that screen. Then you should be able to see what it's
>doing with them.
I'm now convinced this is a bug in com.sun.java.swing.ViewportLayout.java.
A little more experimenting has shown that it's nothing to do with JList.
The preferred size stuff is implemented in JComponent and not overridden.
You can, for example, use a JTextArea with the same effect, or even a
JLabel.
The last few lines in ViewportLayout appear to be the culprit:
public void layoutContainer(Container parent)
{
JViewport vp = (JViewport)parent;
Component view = vp.getView();
Scrollable scrollableView = null;
<snip>
/* If the orgin of the view is showing and the viewport is
* bigger than the views preferred size, then make the view
* the same size as the viewport.
*/
if ((viewPosition.y == 0) && (vpSize.height > viewPrefSize.height)) {
viewPrefSize.height = vpSize.height;
}
if ((viewPosition.x == 0) && (vpSize.width > viewPrefSize.width)) {
viewPrefSize.width = vpSize.width;
}
vp.setViewPosition(viewPosition);
vp.setViewSize(viewPrefSize);
}
}
This clearly makes the view's size bigger if necessary to fill an overlarge
viewport, but never makes it smaller again. The code in ScrollPaneLayout
seems to imply they haven't taken account of the case where the view has had
an explicit size assigned to it, but I haven't yet got to the bottom of all
the interactions.
There's a note from Jeff Teague in the bug parade that looks similar ("I
think this is a bug with ViewportLayout, but I'm just guessing.") but I
didn't find an actual bug report. Can anybody with more knowledge either:
(a) confirm/deny whether this is a bug that's been reported (or tell me the
best way to do so), or
(b) confirm whether the bug exists in later releases. I'm using 1.0.1 and
don't especially want to upgrade until there's a 1.2 production release.
Cheers, Dave
Technical Details
Message-ID:
<72ni1c$ob11@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<727hon$ov14@forums.borland.com> <72fu3o$d5n28@forums.borland.com> <364D2037.7227@flash.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,1177ab7a6295220d X-Google-Attributes: gid111d45,public From: "Dave Howorth" <5bx@iname.com> Subject: ViewportLayout bug? (was Re: JList size in a JScrollPane?) Date: 1998/11/15 Message-ID: <72ni1c$ob11@forums.borland.com> X-Deja-AN: 412175319 References: <727hon$ov14@forums.borland.com> <72fu3o$d5n28@forums.borland.com> <364D2037.7227@flash.net> X-MimeOLE: Produced By Microsoft MimeOLE V4.71.1712.3 Organization: Another Netscape Collabra Server User Newsgroups: borland.public.jbuilder.java.swing