Here you can find the source of setListModel(ListModel model, JList list)
private static void setListModel(ListModel model, JList list)
//package com.java2s; //License from project: Open Source License import javax.swing.*; public class Main { private static void setListModel(ListModel model, JList list) { list.setModel(model);/*from ww w . j a v a 2 s . com*/ if (model.getSize() > 0) { list.setSelectedIndex(0); } } }