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. SQL 中 replace 替换字符串中的字符 ''

    update CfmRcd set reconsource=replace(reconsource,'''',''), cmffile =replace(cmffile,'''',''), cfmda ...

  2. 关于angular的$resource中的isArray属性问题

    在之前的文章中讲到了在使用$resource的时候,有一个isArray属性. 这个属性在两个地方有提到: 1. angular学习笔记(二十八)-$http(6)-使用ngResource模块构建R ...

  3. javascript基础拾遗(二)

    1.对象定义 定义属性 var language = { name:'javascript', score:9.0 }; console.log(language.name) console.log( ...

  4. 每日英语:China Destroys Six Tons of Confiscated Ivory

    BEIJING—Chinese government officials destroyed more than six tons of ivory that had been illegally s ...

  5. python(46):对字典进行排序,多键值排序

    注:改于2017-12-07,python3 下 Removed dict.iteritems(), dict.iterkeys(), and dict.itervalues(). Instead: ...

  6. 使用 CocoaPods 给微信集成 SDK 打印收发消息

    使用 CocoaPods 给微信集成 SDK 打印收发消息 推荐序 本文介绍的是一套逆向工具,可以在非越狱手机上给任意应用增加插件.在文末的示例中,作者拿微信举例,展示出在微信中打印收发消息的功能. ...

  7. Spark SQL inferSchema实现原理探微(Python)【转】

    使用Spark SQL的基础是“注册”(Register)若干表,表的一个重要组成部分就是模式,Spark SQL提供两种选项供用户选择:   (1)applySchema     applySche ...

  8. SolrCloud基本过程

    转:http://www.data321.com/yunjisuan/20160514880/SolrZhiJieDuQuZKZhongDePeiZhiXin SolrCloud之分布式索引及与Zoo ...

  9. Python爬虫技巧

    Python爬虫技巧一之设置ADSL拨号服务器代理 reference: https://zhuanlan.zhihu.com/p/25286144 爬取数据时,是不是只能每个网站每个网站的分析,有没 ...

  10. django源码解析之BigIntegerField (一)

    要分析django的源码,来更深入的学习django,是一个不错的方法,可惜需要大量的时间. 所以,能分析多少就是多少吧. 本次源码分析以1.4.16为基础. 用sublime 打开下载的源码,使用 ...