e782. 排列JList中的项
By default, the items in a list are arranged vertically, in a single column, as in:
item1
item2
...
It is possible to arrange the items left-to-right and top-to-bottom, as in:
item1 item2
item3 item4
item5 ...
This example creates and configures a list that displays its items left-to-right and top-to-bottom. Note that the number of columns can change as the width of the list changes.
// Create a scrollable list
String[] items = {"A", "B", "C", "D"};
JList list = new JList(items);
JScrollPane scrollingList = new JScrollPane(list); // The default layout orientation is JList.VERTICAL
int orient = list.getLayoutOrientation(); // Change the layout orientation to left-to-right, top-to-bottom
list.setLayoutOrientation(JList.HORIZONTAL_WRAP);
The items can also be arranged top-to-bottom and left-to-right, as in:
item1 item4
item2 item5
item3 ...
This example changes the layout orientation so that its items are displayed top-to-bottom and left-to-right.
// Change orientation to top-to-bottom, left-to-right layout
list.setLayoutOrientation(JList.VERTICAL_WRAP);
With some look and feels, a list is set to display a fixed number of rows. In order to make the number of visible rows dependent on the height of the list, the visibleRowCount property must be set to 0:
// Make the number of rows dynamic
list.setVisibleRowCount(0);
| Related Examples |
e782. 排列JList中的项的更多相关文章
- jquery选中将select下拉框中一项后赋值给text文本框
jquery选中将select下拉框中一项后赋值给text文本框,出现无法将第一个下拉框的value赋值给文本框 因为select默认选中第一项..在选择第一项时,便导致无法激发onchange事件. ...
- React 点击删除列表中对应项(React 获取DOM中自定义属性)
点击删除按钮,删除列表中对应项本来是React比较基础的应用,可是应用情况变得复杂了以后,我还真想了一会儿才搞定. 简化一下应用场景:点击新增按钮,增加一条输入框,点击输入框旁边的按钮,删除该输入框( ...
- RCP:如何把Preferences中的项从一个类别移动到另一个类别 2013-08-23 18:59 by Binhua Liu,
RCP:如何把Preferences中的项从一个类别移动到另一个类别 前言 很久没写文章了,准备写一系列关于Eclipse RCP /Plugin的文章. 这些文章都是trouble shooting ...
- [ 记录 ] Vue 对象数组中一项数据改变,页面不更新
问题描述:将data中数据列表渲染到页面,循环生成 el-switch,点击页面中 el-switch 后数组中某项值改变,但是页面不更新 数据格式如下 export default{ data(){ ...
- TFS中工作项的定制-修改面板
上一篇文章我们讲到了<TFS 中工作项的订制-修改工作流>,工作流只要我们设计出来,就可以进行定制修改了.这次通过简单的案例,了解一下,工作项的面板如何定制. 1.软件准备 ...
- 如何自定义TFS中工作项的字段20141010
如何自定义TFS中工作项的字段 我们以VS2013为例,TFS也是2013版本的: 1. 安装小插件 需要安装Visual Studio Team Foundation Server 2013 Pow ...
- CSS中列表项list样式
CSS列表属性 属性 描述 list-style-属性 用于把所有用于列表的属性设置于一个声明中. list-style-image 将图象设置为列表项标志. list-style-position ...
- C# winform listBox中的项上下移动(转)
C# winform listBox中的项上下移动 分类: C# winform2009-06-24 12:37 876人阅读 评论(0) 收藏 举报 winformc#object //上移节点 ...
- 如何为Redis中list中的项设置过期时间
问题 两种解决方法 有序集合 多个集合以及TTL Redis是一个伟大的工具,用来在内存中存储列表是很合适的. 不过,如果你想要快速搜索列表,同时需要让列表中每项都在一定时间后过期,应该怎么做呢? 首 ...
随机推荐
- 高级数据库及一步一步搭建versant数据库
总的来说,高级数据库课程分为分布式数据库和面向对象数据库两块.分布式数据库介绍了分布式数据库的方方面面,包括数据库系统的设计.查询处理优化.事务管理和恢复.并发控制.可靠性.安全性与目录管理等.面向对 ...
- javascript基础拾遗(三)
1.map数组映射操作 function add(x) { return x+1 } var nums = [1,3,5,7,9] result = nums.map(add) console.log ...
- 部署ArcGIS JS API 离线包(Tomcat与IIS)
http://www.cnblogs.com/ventlam/archive/2012/12/13/2815583.html
- vue 实现右键功能
@contextmenu.prevent="rightShow()" v-on:contextmenu.prevent = "事件名称"
- openfire维持在线状态,监听消息
public static void testLoginStatus()throws XMPPException,InterruptedException { AccountManager accou ...
- 分析jvm线程堆栈
目录 一.java线程状态 二.使用jstack生成进程dump文件 三.统计dump文件中处于不同状态的线程数量 四.举例分析不同状态的线程 1.分析BLOCKED (on object monit ...
- 如何在 Django 中保证并发的数据一致性
1. 关于锁 1.1 乐观锁 乐观锁的出发点是,同一条数据很少会因为并发修改而产生冲突,适用于读多写少的场景,用以提高吞吐量. 实现方式,读取一个字段,执行处理逻辑,当需要更新数据时,再次检查该字段是 ...
- 【Java】LinkedBlockingQueue、PriorityQueue and ConcurrentLinkedQueue
1.LinkedBlockingQueue: 基于链接节点的可选限定的blocking queue . 这个队列排列元素FIFO(先进先出). 队列的头部是队列中最长的元素. 队列的尾部是队列中最短时 ...
- idea 换行设置
- web spring 容器
使用spring的web应用时,不用手动创建spring容器,而是通过配置文件声明式地创建spring容器,因此,在web应用中创建spring容器有如下两种方式: 一.直接在web.xml文件中配置 ...