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中的项的更多相关文章

  1. jquery选中将select下拉框中一项后赋值给text文本框

    jquery选中将select下拉框中一项后赋值给text文本框,出现无法将第一个下拉框的value赋值给文本框 因为select默认选中第一项..在选择第一项时,便导致无法激发onchange事件. ...

  2. React 点击删除列表中对应项(React 获取DOM中自定义属性)

    点击删除按钮,删除列表中对应项本来是React比较基础的应用,可是应用情况变得复杂了以后,我还真想了一会儿才搞定. 简化一下应用场景:点击新增按钮,增加一条输入框,点击输入框旁边的按钮,删除该输入框( ...

  3. RCP:如何把Preferences中的项从一个类别移动到另一个类别 2013-08-23 18:59 by Binhua Liu,

    RCP:如何把Preferences中的项从一个类别移动到另一个类别 前言 很久没写文章了,准备写一系列关于Eclipse RCP /Plugin的文章. 这些文章都是trouble shooting ...

  4. [ 记录 ] Vue 对象数组中一项数据改变,页面不更新

    问题描述:将data中数据列表渲染到页面,循环生成 el-switch,点击页面中 el-switch 后数组中某项值改变,但是页面不更新 数据格式如下 export default{ data(){ ...

  5. TFS中工作项的定制-修改面板

    上一篇文章我们讲到了<TFS 中工作项的订制-修改工作流>,工作流只要我们设计出来,就可以进行定制修改了.这次通过简单的案例,了解一下,工作项的面板如何定制.     1.软件准备     ...

  6. 如何自定义TFS中工作项的字段20141010

    如何自定义TFS中工作项的字段 我们以VS2013为例,TFS也是2013版本的: 1. 安装小插件 需要安装Visual Studio Team Foundation Server 2013 Pow ...

  7. CSS中列表项list样式

    CSS列表属性 属性 描述 list-style-属性 用于把所有用于列表的属性设置于一个声明中. list-style-image 将图象设置为列表项标志. list-style-position ...

  8. C# winform listBox中的项上下移动(转)

    C# winform listBox中的项上下移动 分类: C# winform2009-06-24 12:37 876人阅读 评论(0) 收藏 举报 winformc#object //上移节点   ...

  9. 如何为Redis中list中的项设置过期时间

    问题 两种解决方法 有序集合 多个集合以及TTL Redis是一个伟大的工具,用来在内存中存储列表是很合适的. 不过,如果你想要快速搜索列表,同时需要让列表中每项都在一定时间后过期,应该怎么做呢? 首 ...

随机推荐

  1. .NET MVC下的日志文件生成法

    /// <summary> /// 写日志文件 /// </summary> /// <param name="Infos">日志内容</ ...

  2. [转]Web App 框架选择之百度&腾讯

    百度的GMU GMU(Global Mobile UI)是百度前端通用组开发的移动端组件库,GMU是基于zepto的mobile UI组件库,提供webapp.pad端简单易用的UI组件.具有代码体积 ...

  3. Android 编程下通过 Theme 和 Style 避免 APP 启动闪黑屏

    之前在做 APP 的时候不太关注这个问题,因为自己在使用其他 APP 的时候也会在应用启动的初始有一个黑屏闪过后才会出现应用的欢迎页.直到最近开发过程中发现自己在欢迎页启动的线程由于请求和处理的数据量 ...

  4. [DIOCP3-IocpTask说明书]基于IOCP引擎的多线程任务的投递和回调处理单元

    [说明] IocpTask是基于Iocp引擎的多线程任务投递和处理单元,可以方便的把任务进行投递到IOCP线程进行统一调度和处理,是模仿QDAC-QWorker的处理方式,支持D7以上的版本. [使用 ...

  5. Spark提交任务提示 com.mysql.jdbc.Driver Class not found

    com.mysql.jdbc.Driver Not Found 提示很奇怪,在sbt文件中已经引用了,编译也没有问题: "mysql" % "mysql-connecto ...

  6. 【Tensorflow】设置显存自适应,显存比例

    用惯了theano.再用tensoflow发现一运行显存就满载了,吓得我吃了一个苹果. 用天朝搜索引擎毛都搜不到,于是FQ找了下问题的解决方法,原来有两种 按比例 config = tf.Config ...

  7. Docker、Dockerfile、Docker镜像、容器这些都是什么鸟?

    老生常谈,再再再……普及一下: Docker:最早是dotCloud公司出品的一套容器管理工具,但后来Docker慢慢火起来了,连公司名字都从dotCloud改成Docker. Dockerfile: ...

  8. python调用.net动态库

    # python调用.net动态库 ### pythonnet简介------------------------------ pythonnet是cpython的扩展- pythonnet提供了cp ...

  9. C# winform打包(带数据库安装)<转>

    使用VS自带的打包工具,制作winform安装项目 开发环境:VS2008 Access 操作系统:Windows XP 开发语言:C# 项目名称:**管理系统 步骤: 1.打开开发环境VS2010, ...

  10. One-hot 编码/TF-IDF 值来提取特征,LAD/梯度下降法(Gradient Descent),Sigmoid

    1. 多值无序类数据的特征提取: 多值无序类问题(One-hot 编码)把“耐克”编码为[0,1,0],其中“1”代表了“耐克”的中 间位置,而且是唯一标识.同理我们可以把“中国”标识为[1,0],把 ...