当前位置:网站首页>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);//把滚动条显示到控制面板上
边栏推荐
- [Headline] Written test questions - minimum stack
- An Enhanced Model for Attack Detection of Industrial Cyber-Physical Systems
- go语言标准库fmt包怎么使用
- Unknown CMake command “add_action_files“
- 146. LRU cache
- 短视频seo搜索优化主要内容
- Pytorch seq2seq 模型架构实现英译法任务
- CRS management and maintenance
- JSP如何使用page指令让JSP文件支持中文编码呢?
- 回顾历史5次经济衰退时期:这一次可能会有何不同?
猜你喜欢

An interesting project--Folder comparison tool (1)

These 4 computer notepad software, you have to try

PHP从txt文件中读取数据的方法

How to design a circular queue?Come and learn~

Quick solution for infix to suffix and prefix expressions

图解LeetCode——1161. 最大层内元素和(难度:中等)
![[HCIP] BGP Small Experiment (Federation, Optimization)](/img/a2/0967200c69cff3b683dc0af6f314c8.png)
[HCIP] BGP Small Experiment (Federation, Optimization)

bgp aggregation reflector federation experiment

c语言字符和字符串函数总结(二)

NFT工具合集
随机推荐
22. The support vector machine (SVM), gaussian kernel function
els block deformation judgment.
测试用例:四步测试设计法
07-SDRAM :FIFO控制模块
扑克牌问题
不要用jOOQ串联字符串
IP核:FIFO
146. LRU 缓存
Cyber-Physical System State Estimation and Sensor Attack Detection
Redis - message publish and subscribe
回顾历史5次经济衰退时期:这一次可能会有何不同?
JSP request对象功能详解说明
JSP out.print()和out.write()方法的不同之处
els block deformation
What is it like to trade for a living?
unity2D横版游戏教程5-UI
Multidimensional Correlation Time Series Modeling Method Based on Screening Partial Least Squares Regression of Correlation Variables
els 方块变形
c语言字符和字符串函数总结(二)
Grid false data injection attacks detection based on coding strategy