This is the mail archive of the
java-prs@gcc.gnu.org
mailing list for the Java project.
[Bug swing/17360] JScrollPane has incorrect size when JList with specified size is added to it
- From: "abalkiss at redhat dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: java-prs at gcc dot gnu dot org
- Date: 26 Oct 2005 15:23:57 -0000
- Subject: [Bug swing/17360] JScrollPane has incorrect size when JList with specified size is added to it
- References: <bug-17360-8730@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from abalkiss at redhat dot com 2005-10-26 15:23 -------
This appears to be a problem with JScrollPane.getPreferredSize(), as the
FlowLayout sets the size of the JScrollPane to its preferredSize, and then this
is a bound for the layout in ScrollPaneLayout which then sets an inappropriate
size for the JViewport.
The simple testcase below shows that JScrollPane is returning an inappropriate
value for getPreferredSize.
***TESTCASE***
import java.awt.*;
import javax.swing.*;
class Test2
{
public static void main(String[] args)
{
JFrame f = new JFrame();
String[] items =
{
"Item1", "Item2", "Item3", "Item4", "Item5", "Item6",
"Item7", "Item8", "Item9", "Item10", "Item11"
};
JList list = new JList(items);
list.setPreferredSize(new Dimension(150, 150));
f.setLayout(new FlowLayout());
JScrollPane scroller = new JScrollPane(list);
System.out.println ("scroll pane pref size: "+scroller.getPreferredSize());
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17360