Here you can find the source of getListItems(JList list)
public static Object[] getListItems(JList list)
//package com.java2s; //License from project: Apache License import javax.swing.*; public class Main { public static Object[] getListItems(JList list) { ListModel lm = list.getModel(); synchronized (lm) { Object[] ret = new Object[lm.getSize()]; for (int i = 0; i < ret.length; i++) { ret[i] = lm.getElementAt(i); }// w w w.ja va 2 s. c o m return ret; } } }