List selection events are fired when the following methods are used to change the set of selected items (see e774 创建JList组件).

    // Create a list and get the model
String[] items = {"A", "B", "C", "D"};
JList list = new JList(items); // Select the second item
int start = 1;
int end = 1;
list.setSelectionInterval(start, end); // B // Select the first 3 items
start = 0;
end = 2;
list.setSelectionInterval(start, end); // A, B, C // Select all the items
start = 0;
end = list.getModel().getSize()-1;
if (end >= 0) {
list.setSelectionInterval(start, end); // A, B, C, D
} // Clear all selections
list.clearSelection(); // Select the first item
start = 0;
end = 0;
list.setSelectionInterval(start, end); // A // Add another selection - the third item
start = 2;
end = 2;
list.addSelectionInterval(start, end); // A, C // Deselect the first item
start = 0;
end = 0;
list.removeSelectionInterval(start, end); // C // Select a single item
boolean scrollIntoView = true;
list.setSelectedValue("B", scrollIntoView); // B
Related Examples

e780. 设置JList中的已选项的更多相关文章

  1. e779. 获得JList中的已选项

    The following methods return the indices of the selected items: // To create a list, see e774 创建JLis ...

  2. e781. 设置JList中的选择模式

    // The default mode is MULTIPLE_INTERVAL_SELECTION String[] items = {"A", "B", & ...

  3. 【MyEclipse优化】-----如何合理设置MyEclipse中的validation选项

    打开eclipse,点击[window]菜单,选择[preferences]选项. 在左侧点击[validation]选项,在右侧可以看到eclipse进行的自动检查都有哪些内容. 将Manual(手 ...

  4. MyEclipse优化】-----如何合理设置MyEclipse中的validation选项

    打开eclipse,点击[window]菜单,选择[preferences]选项. 在左侧点击[validation]选项,在右侧可以看到eclipse进行的自动检查都有哪些内容. 将Manual(手 ...

  5. Bash中的shopt选项

    Bash中的shopt选项 http://blog.chinaunix.net/uid-20587169-id-1919110.html shopt命令用于显示和设置shell中的行为选项,通过这些选 ...

  6. windows7下系统保护中出现错误“文件名、目录名或卷标语法不正确。(0x8007007B)“ 以及保护设置列表中出现“Windows7_os(c:)(找不到)”选项时的解决方法

    windows7下系统保护功能很是鸡肋,有事会出现一下两个问题: 1.出现错误“文件名.目录名或卷标语法不正确.(0x8007007B) 2.保护设置列表中出现“Windows7_os(c:)(找不到 ...

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

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

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

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

  9. 修改 /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 ...

随机推荐

  1. Nan-boxing技术介绍

    NaN-boxing看起来像英文翻译的“南拳”,其实它是表示一个无效的double数.NaN-boxing技术:通过一个64位的数字来表示多种数据类型的技术,它通过一个nan浮点数来保存数据,根据IE ...

  2. shutil 高级文件操作

    High-level file operations  高级的文件操作模块,官网:https://docs.python.org/2/library/shutil.html# os模块提供了对目录或者 ...

  3. 每日英语:Booming Tech Sector Redraws the Map

    China's high-tech companies have made their mark on the nation's economy. Now, with growing cash and ...

  4. Lua语法基础(1)---简介、基本数据类型、表达式

    我觉得我已经陷入了一个坑内.因为,安装了Lua和SublimeText3编辑器之后,怎么使自己编写的lua代码在untiy内运行起来,是个我完全不了解的机制.先放一放吧.首先,来回顾一下Lua的语法基 ...

  5. 前端建立一个本地服务器:browser-sync

    1.安装browser-sync: npm i browser-sync --save-dev 2.在package.json中添加启动代码: "start": "./n ...

  6. pip3 install jupyter出现错误

    问题描述 出现如下错误: Command "/Users/wang/.pyenv/versions/3.3.1/bin/python3.3 -u -c "import setupt ...

  7. spring filter 配置

    web xml <filter>    <filter-name>DelegatingFilterProxy</filter-name>    <filter ...

  8. Creating a Physical Standby Database 11g

    1.Environment Item Primary database standby database Platform Redhat 5.4 Redhat 5.4 Hostname gc1 gc2 ...

  9. 用B表更新A表

    UPDATE dbo.POR_LOT SET POR_LOT.SHIPPED_FLAG =B.SHIPPED_FLAGFROM POR_LOT A INNER JOIN ( SELECT T5.LOT ...

  10. Java heap space cdh 5.11.1

    在执行hive count 查询的时候报错:Error: Java heap space 解决办法是 set io.sort.mb=10; 执行hadoop的Exeample的时候报错,也是java ...