This week's book / license giveaways are in the JDBC and Relational Databases and Java in General forums.
We're giving away four copies each of PostGIS in Action and Java Advanced Topics Training and have the authors on-line!
See this thread and this one for details.
The moose likes Swing / AWT / SWT and the fly likes JList width Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JList width" Watch "JList width" New topic
Author

JList width

Kevin Tysen
Ranch Hand

Joined: Oct 12, 2005
Posts: 255
I have a JList inside a ScrollPane. I set the vertical size by using the .setVisibleRowCount method, so now the height is always the same height, and when the number of options is large enough, it scrolls. I want to do the same kind of thing to the width, but I looked in the JList API and didn't see anything that seems to work. The width keeps changing depending on what is in the list. How can I set the width?
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
give the scrollpane a preferredSize
e.g.
scrollPane.setPreferredSize(new Dimension(100,200));
Kevin Tysen
Ranch Hand

Joined: Oct 12, 2005
Posts: 255
Thank you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JList width