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. Delphi对象池MyObjectPool.pas

    对象池一般在服务端使用,所以稳定性是第一的. 欢迎提意见 unit uMyObjectPool; interface uses SyncObjs, Classes, Windows, SysUtils ...

  2. lua脚本之lua语言简介以及lua的安装

    本博主不擅于进行文字创作,所以,相当一部分文字皆复制于其他博文.还希望能够得到谅解.  一.Lua语言简介 Lua是一个免费的开源软件,可以免费用于科研及商业.Lua具有一个专家团队在维护和升级,其设 ...

  3. iOS - UITableView加载网络图片 cell适应图片高度

    使用xib创建自定制cell   显示图片   创建一个继承UITableViewCell的类   勾选xib 如下是xib创建图 xib 向.h拖拽一个关联线 .h .m 2.代码创建(使用三方适配 ...

  4. Android NFC近场通信1——NFC概述

    最近对NFC挺感兴趣,而且新换的手机也支持NFC功能(最近换了Find5,感觉还不错O(∩_∩)O),所以打算学学NFC编程.NFC就是我们经常说的近场通信.通常距离是4厘米或更短.NFC工作频率是1 ...

  5. iOS five years[转]

    原文链接:http://blog.ayaka.me/post/127980091987/5-years This morning, I got a push notification from Tim ...

  6. WPF中的命令简介

    使用Prism委托命令Demo: WPF委托命令DelegateCommand的传参方式 在WPF中使用命令的步骤很简单 1.创建命令 2.绑定命令 3.设置命令源 4.设置命令目标 WPF中命令的核 ...

  7. [watchdog]内核失败的重启方案

    1 在内核中配置看门狗驱动Linux-2.6.32.2 内核具有完善的S3C2440 的看梦狗驱动,我们只需配置一下就可以使用了.在内核源代码目录执行:make menuconfig,进入内核配置主菜 ...

  8. pthread_cond_wait和pthread_cond_signal以及互斥变量的使用情况

    #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <pthread.h& ...

  9. Java编程的逻辑 (50) - 剖析EnumMap

    本系列文章经补充和完善,已修订整理成书<Java编程的逻辑>,由机械工业出版社华章分社出版,于2018年1月上市热销,读者好评如潮!各大网店和书店有售,欢迎购买,京东自营链接:http:/ ...

  10. Drupal 7 配置ckeditor和ckfinder编辑器实现图片上传--不用wysisyg

    注意: 1.这里的ckeditor编辑器是独立模块,不是那个wysiwyg模块. 2.这里的图片上传仅仅为文章内图片,非字段图片.   1.下载文件(1) http://drupal.org/proj ...