Here you can find the source of fillList(Collection anList, JList anJList)
Parameter | Description |
---|---|
anList | List |
anJList | JList |
public static void fillList(Collection anList, JList anJList)
//package com.java2s; //License from project: LGPL import java.util.*; import javax.swing.*; public class Main { /**/*from w w w .ja va 2s. c o m*/ * fillList * * @param anList List * @param anJList JList */ public static void fillList(Collection anList, JList anJList) { DefaultListModel listModel = new DefaultListModel(); if (anList != null && anJList != null) { Object el = null; Iterator it = anList.iterator(); while (it.hasNext()) { el = it.next(); listModel.addElement(el); } } anJList.setModel(listModel); if (listModel.size() > 0) { anJList.setSelectedIndex(0); } } }