当前位置:网站首页>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);//把滚动条显示到控制面板上
边栏推荐
- What does the errorPage attribute of the JSP page directive do?
- C language character and string function summary (2)
- 【HCIP】BGP小型实验(联邦,优化)
- The Statement update Statement execution
- Disk and file system management
- How to find new potential projects?Tools recommended
- MySQL常用语句整理
- 回顾历史5次经济衰退时期:这一次可能会有何不同?
- 使用jOOQ将Oracle风格的隐式连接自动转换为ANSI JOIN
- Don't concatenate strings with jOOQ
猜你喜欢

短视频seo搜索优化主要内容

Interview high-frequency test questions solution - stack push and pop sequence, effective parentheses, reverse Polish expression evaluation

nodeJs--mime模块

22. The support vector machine (SVM), gaussian kernel function

Are test points the same as test cases?

A simple file transfer tools

众筹DAO“枯萎”的缩影:曾拍下《沙丘》未出版手稿的Spice DAO解散

IP核:FIFO

These 4 computer notepad software, you have to try

图解LeetCode——1161. 最大层内元素和(难度:中等)
随机推荐
ROS 动态参数
Collection of NFT tools
c语言字符和字符串函数总结(二)
玩转NFT夏季:这份工具宝典值得收藏
MySQL常用语句整理
Arduino Basic Syntax
Difference between JSP out.print() and out.write() methods
632. Minimum interval
PHP从txt文件中读取数据的方法
String splitting function strtok exercise
These 4 computer notepad software, you have to try
Graphical LeetCode - 1161. Maximum Sum of In-Layer Elements (Difficulty: Moderate)
BGP 第一次实验
bgp aggregation reflector federation experiment
632. 最小区间
业务测试如何避免漏测 ?
Interview high-frequency test questions solution - stack push and pop sequence, effective parentheses, reverse Polish expression evaluation
Task execution control in Ansible
Play NFT summer: this collection of tools is worth collecting
Async/await principle and execution sequence analysis