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. 详细介绍Base64的编码转换方式

    下面,详细介绍Base64的编码转换方式. 所谓Base64,就是说选出64个字符----小写字母a-z.大写字母A-Z.数字0-9.符号"+"."/"(再加上 ...

  2. 每日英语:Does China Face a Reading Crisis?

    For much of the last year, intellectuals and officials in China -- land of world-beating students an ...

  3. lua 的 table 处理

    lua 的整体效率是很高的,其中,它的 table 实现的很巧妙为这个效率贡献很大. lua 的 table 充当了数组和映射表的双重功能,所以在实现时就考虑了这些,让 table 在做数组使用时尽量 ...

  4. spark on alluxio和MR on alluxio测试(改进版)【转】

    转自:http://kaimingwan.com/post/alluxio/spark-on-alluxiohe-mr-on-alluxioce-shi-gai-jin-ban 1. 介绍 2. 准备 ...

  5. hdu1839(二分+优先队列,bfs+优先队列与spfa的区别)

    题意:有n个点,标号为点1到点n,每条路有两个属性,一个是经过经过这条路要的时间,一个是这条可以承受的容量.现在给出n个点,m条边,时间t:需要求在时间t的范围内,从点1到点n可以承受的最大容量... ...

  6. 查询Oracle性能差的、正在执行或执行过的SQL语句

    查找前十条性能差的sql. SELECT * FROM (select PARSING_USER_ID,EXECUTIONS,SORTS, COMMAND_TYPE,DISK_READS,sql_te ...

  7. JAVA-数据库之JDBC连接MySQL数据库

    相关资料:<21天学通Java Web开发> JDBC连接MySQL数据库1.如果需要通过JDBC来连接MySQL数据库,还必须先在MySQL数据库服务器中创建数据库和表. Connect ...

  8. JAVA-JSP内置对象之request获得参数的所有参数值(多个值)

    相关资料:<21天学通Java Web开发> 获得参数的所有参数值(多个值)1.需要使用request对象的getParameterValues()方法. RequestForm4.jsp ...

  9. [转]操作MySQL数据库报出:Parameter index out of range (1 > number of parameters, which is

    原文地址:https://blog.csdn.net/zdx_y/article/details/52072914 对MySQL进行insert操作,控制台抛出以下错误:Parameter index ...

  10. WPF 系列学习

    WPF CheckBox 自定义样式 给Button设置ToolTip 圆角Button 样式