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

4

10

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?

Wolters answered 16/1, 2012 at 21:19 Comment(0)
N
14

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.

Nylon answered 16/1, 2012 at 21:24 Comment(0)
O
8

As of JDK1.7 it was replaced with public List<E> getSelectedValuesList(). http://docs.oracle.com/javase/7/docs/api/javax/swing/JList.html#getSelectedValuesList%28%29

Openeyed answered 16/1, 2012 at 21:23 Comment(0)
G
5

use getSelectedValuesList instead.

So, use public List<E> getSelectedValuesList().

It returns:

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

Guaiacol answered 16/1, 2012 at 21:23 Comment(0)
L
5

Please use getSelectedValuesList. Here is the link to the API documentation getSelectedValuesList.

Lusitania answered 16/1, 2012 at 21:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.