JList inside JScrollPane is not displaying
Hello. I've got a problem with a JList. I create a JScrollPane and place my JList inside it, then set the preferred size of the JScrollPane. When the GUI is shown, my JScrollPane is visible and has the correct size, however, the JList appears to have zero width and height (according to the debugger). When I add elements to JList's model they are added correctly, but the list is still invisible.
Here's some code.
In the panel constructor (it has a BorderLayout, and the JScrollPane with my list is added to the left side):
Code:
pictures = new DefaultListModel();
pictures.addElement("test");
picList = new JList(pictures);
picList.setLayoutOrientation(JList.VERTICAL);
picList.setVisibleRowCount(20);
picList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JScrollPane pPic = new JScrollPane(picList);
pPic.setPreferredSize(new Dimension(200, 0));
pPic.add(picList);
add(pPic, BorderLayout.WEST);
Here is what it looks like:
http://i.imgur.com/Y7FVr.jpg
As you can see, there's an empty space on the left side, where my list is supposed to be. Thank you very much for any help.