当前位置:网站首页>swing的Jlist列表滚动条以及增加元素的问题
swing的Jlist列表滚动条以及增加元素的问题
2022-08-02 00:13:00 【安卓世界库】
一般新建列表用,都要增加元素,元素多了以后要有滚动条,这么简单的问题,但是网上的回答乱七八糟根本就没法用。现在总结如下:
Jlist创建出来后,就是个壳子,上述功能必须给绑定上去。
JList list = new JList(mlist);
1绑定增加元素的属性。
DefaultListModel<String> mlist = new DefaultListModel();
JList list = new JList(mlist);
这样就可以用, mlist.add(0, "停止点击");进行操作。
2.绑定滚动条
JScrollPane scrollPane = new JScrollPane(list));//绑定滚动条
scrollPane.setAutoscrolls(true);//自动滚动条
scrollPane.setBounds(20,90,470,550);//显示区域
contentPane.add(scrollPane);//把滚动条显示到控制面板上
边栏推荐
- JSP内置对象out对象的功能简介说明
- Async/await principle and execution sequence analysis
- Simpson's paradox
- After an incomplete recovery, the control file has been created or restored, the database must be opened with RESETLOGS, interpreting RESETLOGS.
- 短视频seo搜索优化主要内容
- 信息物理系统状态估计与传感器攻击检测
- nodeJs--各种路径
- Redis - message publish and subscribe
- MySQL常用语句整理
- These 4 computer notepad software, you have to try
猜你喜欢
Graphical LeetCode - 1161. Maximum Sum of In-Layer Elements (Difficulty: Moderate)
Don't concatenate strings with jOOQ
Knowing the inorder traversal of the array and the preorder traversal of the array, return the postorder history array
uni-app project summary
Short video SEO optimization tutorial Self-media SEO optimization skills and methods
Collection of NFT tools
What is Low-Code?What scenarios is low code suitable for?
微软电脑管家V2.1公测版正式发布
Short video SEO search operation customer acquisition system function introduction
146. LRU 缓存
随机推荐
How to use the go language standard library fmt package
中缀转后缀、前缀表达式快速解决办法
微软电脑管家V2.1公测版正式发布
06-SDRAM :SDRAM控制模块
els 方块变形
构造方法,this关键字,方法的重载,局部变量与成员变量
Redis - message publish and subscribe
Multidimensional Correlation Time Series Modeling Method Based on Screening Partial Least Squares Regression of Correlation Variables
How to find new potential projects?Tools recommended
Business test how to avoid missing?
Multi-feature fusion face detection based on attention mechanism
不了解SynchronousQueue?那ArrayBlockingQueue和LinkedBlockingQueue不会也不知道吧?
Day11 shell脚本基础知识
Double queue implementation stack?Dual stack implementation queue?
基于相关性变量筛选偏最小二乘回归的多维相关时间序列建模方法
632. Minimum interval
JSP内置对象out对象的功能简介说明
基于注意力机制的多特征融合人脸活体检测
JSP如何使用request获取当前访问者的真实IP呢?
bgp 聚合 反射器 联邦实验