Here you can find the source of indexList(JList list, Object object)
public static int indexList(JList list, Object object)
//package com.java2s; //License from project: LGPL import javax.swing.*; public class Main { public static int indexList(JList list, Object object) { ListModel model = list.getModel(); if (model == null) { model = new DefaultListModel(); list.setModel(model);//from w w w. j a v a2s . c om } ; if (model instanceof DefaultListModel) { DefaultListModel listModel = (DefaultListModel) model; return listModel.indexOf(object); } return -1; } }