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是一个伟大的工具,用来在内存中存储列表是很合适的. 不过,如果你想要快速搜索列表,同时需要让列表中每项都在一定时间后过期,应该怎么做呢? 首 ...
随机推荐
- 定期批量修改远程服务器root密码
一.背景 很多时候运维或安全工作人员需要维护大量的服务器,其中就包括判断是否存在root弱口令, 如果服务器数量很多一一修改的话的确是要好花费不少时间精力的.如果通过脚本来实现密码更改, 再做一个定期 ...
- Django model中的Class Meta
1.Meta元数据 代码示例: class Foo(models.Model): bar = models.CharField(maxlength=30) class Meta: # ... Meta ...
- Delphi对象池MyObjectPool.pas
对象池一般在服务端使用,所以稳定性是第一的. 欢迎提意见 unit uMyObjectPool; interface uses SyncObjs, Classes, Windows, SysUtils ...
- Asp.Net MVC TryUpdateModel使用说明
修改功能每个网站里都有,也有很多写法 写法1:要修改的字段刚好等于表中的字段 [HttpPost] [ValidateAntiForgeryToken] public ActionResult Edi ...
- 【转】MySQL中information_schema是什么
大家在安装或使用MYSQL时,会发现除了自己安装的数据库以外,还有一个information_schema数据库. information_schema数据库是做什么用的呢,使用WordPress博客 ...
- Windows下Python3+nose+appium自动化测试之Android篇
[本文出自天外归云的博客园] 简介 以下用来做自动化测试的这款app叫最爱抓娃娃,以后会改名为网易抓娃娃. 下文提到的appiumier项目里会包含用来测试的apk包以及自动化测试代码. 先说一个坑 ...
- 设计模式之工厂方法模式(代码用Objective-C展示)
前面一篇展示了一个简单工厂模式,这一篇主要是对比,工厂方法模式比简单工厂模式好在哪里?为什么要用这个模式?这个模式的精髓在哪里? 就以计算器为例,结果图如下: 加减乘除运算都是继承自基类运算类,然后工 ...
- Python操作SQLAlchemy之连表操作
多对一连表操作 首先有两个知识点: 改变数据输出的方式:可以在表的类中定义一个特殊成员:__repr__,return一个自定义的由字符串拼接的数据连接方式. 数据库中表关系之间除了MySQL中标准的 ...
- JAVA-JSP内置对象之request获得所有的参数名称
相关资料:<21天学通Java Web开发> 获得所有的参数名称1.request对象的getParameterNames()方法可以获得所有的参数名称. RequestForm2.jsp ...
- mongo源码学习(一)
在git上把mongo的源码给拉下来了,然后目录大概是这样的: 这个mongo是用C++写的,编译并没有用Makefile而是用的scons工具,这个好像是python写的. mongo后台进程的入口 ...