import javax.swing.JList;
public class Main {
public static void main(String[] argv) throws Exception {
String[] items = { "A", "B", "C", "D" };
JList list = new JList(items);
// Get number of items in the list
int size = list.getModel().getSize(); // 4
// Get all item objects
for (int i = 0; i < size; i++) {
Object item = list.getModel().getElementAt(i);
}
}
}