Java - How do I get a all the selected values from a JList?

Alex G picture Alex G · Jan 16, 2012 · Viewed 21.2k times · Source

A struggling Java newbie here - help! I'm trying to: - Get all the selected values from a JList - Create an ArrayList from those values

It seems getSelectedValues is deprecated?

Answer

miku picture miku · Jan 16, 2012

Until JDK 1.6 (deprecated in 1.7):

New since JDK 1.7:

  • public List<E> getSelectedValuesList()

    Returns a list of all the selected items, in increasing order based on their indices in the list.