Here you can find the source of setSelectedList(JList list, Object selected)
Parameter | Description |
---|---|
list | JList |
selected | Object |
public static void setSelectedList(JList list, Object selected)
//package com.java2s; //License from project: LGPL import javax.swing.*; public class Main { /**// ww w .j a v a 2s .c om * * @param list JList * @param selected Object */ public static void setSelectedList(JList list, Object selected) { if (list == null) { return; } if (list.getModel().getSize() == 0) { return; } if (selected == null) { list.setSelectedIndex(0); } else { list.setSelectedValue(selected, true); } } }