简体   繁体   English

Java - 如何从JList获取所有选定的值?

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

A struggling Java newbie here - help! 一个苦苦挣扎的Java新手在这里 - 帮忙! I'm trying to: - Get all the selected values from a JList - Create an ArrayList from those values 我正在尝试: - 从JList获取所有选定的值 - 从这些值创建一个ArrayList

It seems getSelectedValues is deprecated? 似乎getSelectedValues已被弃用?

Until JDK 1.6 (deprecated in 1.7): 直到JDK 1.6(在1.7中弃用):

New since JDK 1.7: JDK 1.7以来的新功能:

  • public List<E> getSelectedValuesList() public List<E> getSelectedValuesList()

    Returns a list of all the selected items, in increasing order based on their indices in the list. 返回所有选定项的列表,根据列表中的索引按升序排列。

As of JDK1.7 it was replaced with public List<E> getSelectedValuesList() . 从JDK1.7开始,它被public List<E> getSelectedValuesList()取代。 http://docs.oracle.com/javase/7/docs/api/javax/swing/JList.html#getSelectedValuesList%28%29 http://docs.oracle.com/javase/7/docs/api/javax/swing/JList.html#getSelectedValuesList%28%29

use getSelectedValuesList instead. 请改用getSelectedValuesList

So, use public List<E> getSelectedValuesList() . 因此,使用public List<E> getSelectedValuesList()

It returns: 它返回:

Returns a list of all the selected items, in increasing order based on their indices in the list. 返回所有选定项的列表,根据列表中的索引按升序排列。

Please use getSelectedValuesList . 请使用getSelectedValuesList Here is the link to the API documentation getSelectedValuesList . 以下是API文档getSelectedValuesList的链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM