This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread 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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JList width" Watch "JList width" New topic

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
scrollPane.setPreferredSize(new Dimension(100,200));
Kevin Tysen
Ranch Hand

Joined: Oct 12, 2005
Posts: 255
Thank you.
subject: JList width
Similar Threads
buttons display problem in IE and FireFox
Different cell sizes for jlist cells
SpringLayout - handcoding
org.eclipse.swt.widgets.List - how to set visibile row count?
howto fix the size of table ?