Here is my code to create a Jlist and filling it up using action listener
At the first place I used an array of string to fill up the Jlist and I had scroller. Then for upating Jlist I need to change the mode of the Jlist to DefaultListModel and as soon as I did that change I lost my scroller.
I donot know what went wrong
Can any one help me please
private Component makeListView() {
final DefaultListModel<String> listModel = new DefaultListModel<String>();
final JList<String> list = new JList<String>(listModel);
list.setModel(listModel);
updateCourseListPanel(listModel);
notifyObserverInModelForClickingOnListItem(list);
list.setPreferredSize(getSize());
list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
list.setLayoutOrientation(JList.HORIZONTAL_WRAP);
list.setVisibleRowCount(-1);
list.setFixedCellWidth(80);
JScrollPane listScroller = new JScrollPane(list);
listScroller.setPreferredSize(getMaximumSize());
setVisible(true);
return list;
}