*
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
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 ?