It looks as though when I put a JTextArea or a JList in a JScrollPane, the component gets maximized over the remaining area of the JPanel it is in:
...
this.topPnl = new JPanel();
this.topPnl.setLayout(new BoxLayout(this.topPnl, BoxLayout.X_AXIS));
this.selFileList = new JList(new String[]{"one", "two", "three", "four"});
JScrollPane scroll = new JScrollPane(this.selFileList);
this.topPnl.add(scroll);
...
If I don't set the JList in a JScrollPane and just add it directly to the JPanel, the JList appears just large enough to display all the items but I want to control the size of the container, i.e. be of fixed size in case the varying number of elements is high and then have the scroll bars, which is the whole idea behind using JScrollPane.
I want to know what I am doing wrong and how I can accomplish what I described above?