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?
posted 9 years ago
give the scrollpane a preferredSize e.g. scrollPane.setPreferredSize(new Dimension(100,200));