The following methods return the indices of the selected items:

    // To create a list, see e774 创建JList组件

    // Get the index of all the selected items
int[] selectedIx = list.getSelectedIndices(); // Get all the selected items using the indices
for (int i=0; i<selectedIx.length; i++) {
Object sel = list.getModel().getElementAt(selectedIx[i]);
} // Get the index of the first selected item
int firstSelIx = list.getSelectedIndex(); // Get the index of the last selected item
int lastSelIx = list.getMaxSelectionIndex(); // Determine if the third item is selected
int index = 2;
boolean isSel = list.isSelectedIndex(index); // Determine if there are any selected items
boolean anySelected = !list.isSelectionEmpty();

The following methods return the selected item objects:

    // Get the first selected item
Object firstSel = list.getSelectedValue(); // Get all selected items without using indices
Object[] selected = list.getSelectedValues();
Related Examples

e779. 获得JList中的已选项的更多相关文章

  1. e780. 设置JList中的已选项

    List selection events are fired when the following methods are used to change the set of selected it ...

  2. vue table中使用多选的问题(翻页后如何保存已选项),联动echarts图表实现流量监控

    流量监控项目需求: 根据表格数据,添加多选功能,默认全选,根据已选项更新图表视图 1.表格需要多选 2.要联动图表,所以关键是要利用表格多选的触发回调函数 vue table中使用多选: 很简单,只需 ...

  3. OJ提交题目中的语言选项里G++与C++的区别(转)

    G++? 首先更正一个概念,C++是一门计算机编程语言,G++不是语言,是一款编译器中编译C++程序的命令而已. 那么他们之间的区别是什么? 在提交题目中的语言选项里,G++和C++都代表编译的方式. ...

  4. OJ提交题目中的语言选项里G++与C++的区别(转载)

    原文链接:http://blog.polossk.com/201405/c-plus-plus-g-plus-plus G++? 首先更正一个概念,C++是一门计算机编程语言,G++不是语言,是一款编 ...

  5. Linux: 介绍make menuconfig中的每个选项含义【转】

    转自:http://blog.csdn.net/gaoyuanlinkconcept/article/details/8810468 介绍make menuconfig中的每个选项含义 Linux 2 ...

  6. 【转】OJ提交题目中的语言选项里G++与C++的区别

    原文链接:http://blog.polossk.com/201405/c-plus-plus-g-plus-plus G++? 首先更正一个概念,C++是一门计算机编程语言,G++不是语言,是一款编 ...

  7. 修改 /var/lib/locales/supported.d/local 文件(使用 locale -a 命令查看系统中所有已配置的 locale)

    转自:http://zyxhome.org/wp/cc-prog-lang/c-stdlib-setlocale-usage-note/ http://www.west263.com/info/htm ...

  8. OJ提交题目中的语言选项里G++与C++的区别

    一.OJ提交题目中的语言选项里G++与C++的区别 http://www.th7.cn/Program/cp/201405/199001.shtml 首先更正一个概念,C++是一门计算机编程语言,G+ ...

  9. ubuntu中查看已安装软件包的方法

    ubuntu中查看已安装软件包的方法: 方法一:在新立得软件包管理器中,打到已安装,便可以看看有多少包被安装. 如果想把这些包的信息复制到一文件里,可用下面的方法. 方法二:在终端输入 sudo dp ...

随机推荐

  1. jqgrid传入的json数据,赋值了但是没有在表格上显示

    1.  datatype: "local",属性加入这个 2. dataValue就是json对象 for (var i = 0; i <= dataValue.length ...

  2. linux命令(39):shell 打印偶数行,奇数行 ,行号

    awk 命令: 1. 打印行号和内容: awk '{print NR":"$0}' 2. 输出:偶数行和奇数行到文件 awk '{print $0.txt > NR%2.tx ...

  3. PBR Metallic/Roughness工作流中Albedo与F0的计算方法

    首先简单回顾一下典型的纯金属与绝缘体的PBR属性: 纯金属: Albedo(diff): 0 F0(spec): >0.3 (or 0.5, epic/allegorithmic etc.) M ...

  4. [DIOCP3/MyBean/QDAC开源项目] DataModule-DB例子基于MyBean的插件实例<三层数据库方案>

    [说明] 这个例子答应大家很久了,一直没有时间弄,现在正式结合MyBean插件可以很方便的在客户端共享操作连接,执行数据库的各项工作,屏蔽了底层的通信解码器编码等工作,直接传递Variant,给了开发 ...

  5. alluxio网络流量异常分析【转】

    1. 介绍 2. 准备工作 2.1 tcpdump 2.2 winshark 2.3 安装iftop 2.4 alluxio网络通信相关的端口 3.iftop 锁定消耗流量最大的端口 4. dump数 ...

  6. 【linux排错】"error while loading shared libraries: xxx.so.x" 错误的原因和解决办法

    一般我们在Linux下执行某些外部程序的时候可能会提示找不到共享库的错误, 比如: lcw: error : cannot open shared object file: No such file ...

  7. 【web技术】html特效代码(二)

    html特效代码(一) html特效代码(二) 图片漂浮广告代码 <bodybgcolor="#F7F7F7"> <!--图片漂浮广告代码开始--> < ...

  8. hive一行变多行及多行变一行

    hive一行变多行及多行变一行 场景 name alias zhaoqiansun abc def ghi 处理数据时需要将上表处理成为下面的形式: name alias zhaoqiansun ab ...

  9. webpack打包调试react并使用babel编译jsx配置方法

    http://lxj8749.iteye.com/blog/2287074 ********************************************** 安装webpack npm i ...

  10. NSOperation和NSOperationQueue的一些基本操作

    当初学习多线程这一块的时候,时间比较匆忙,没有细细考虑,而今重新学一次,算是复习和总结吧. #import "ViewController.h" @interface ViewCo ...