e774. 创建JList组件
组件 创建
2023-09-14 09:11:59 时间
By default, a list allows more than one item to be selected. Also, the selected items need not be contiguous. To change this default, see e781 设置JList中的选择模式.
A list selection event is fired when the set of selected items is changed (see e784 监听对JList选择变动).
// Create a list with some items
String[] items = {"A", "B", "C", "D"};
JList list = new JList(items);
The items can be arbitrary objects. The toString()
method of the objects is displayed in the list component.
// Create a list with two items - "123" and "Sun May 19 21:15:38 PDT 2002"
Object[] items2 = {new Integer(123), new java.util.Date()};
list = new JList(items2);
By default, a list does not automatically display a scrollbar when there are more items than can be displayed. The list must be wrapped in a scroll pane:
JScrollPane scrollingList = new JScrollPane(list);
Related Examples |
相关文章
- Vue3源码09: 组件的渲染和更新流程
- angular4父组件向子组件传值,子组件向父组件传值的方法
- react源码分析:组件的创建和更新
- 宝塔面板安装SourceGuardian组件SG11组件
- 光伏组件IV测试系统
- 【Visual Studio】Visual Studio 2019 社区版 CMake开发环境安装 ( 下载 | 安装相关组件 | 创建编译执行项目 | 错误处理 )
- 【鸿蒙 HarmonyOS】Ability 中使用纯代码绘制布局及 UI 组件
- 【Flutter】StatefulWidget 组件 ( 创建 StatefulWidget 组件 | MaterialApp 组件 | Scaffold 组件 )
- 【Android Gradle 插件】组件化中的 Gradle 构建脚本实现 ① ( 组件化简介 | 创建组件化应用 | 依赖库模块 / 应用模块 切换设置 )
- TrieTree服务-组件构成及其作用介绍
- Yii核心组件AssetManager原理分析
- MySQL基准测试套件Benchmark安装DBI组件过程分享