当前位置:网站首页>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);//把滚动条显示到控制面板上
边栏推荐
- Arduino Basic Syntax
- poker question
- Short video SEO search operation customer acquisition system function introduction
- 构造方法,this关键字,方法的重载,局部变量与成员变量
- Play NFT summer: this collection of tools is worth collecting
- uni-app项目总结
- JSP how to obtain the path information in the request object?
- 中缀转后缀、前缀表达式快速解决办法
- The Statement update Statement execution
- Short video SEO optimization tutorial Self-media SEO optimization skills and methods
猜你喜欢
随机推荐
poker question
在不完全恢复、控制文件被创建或还原后,必须使用 RESETLOGS 打开数据库,解释 RESETLOGS.
攻防世界-web-Training-WWW-Robots
NodeJs, all kinds of path
使用jOOQ将Oracle风格的隐式连接自动转换为ANSI JOIN
IO流基础
中缀转后缀、前缀表达式快速解决办法
以交易为生是一种什么体验?
Arduino Basic Syntax
2022/08/01 Study Notes (day21) Generics and Enums
Play NFT summer: this collection of tools is worth collecting
【21天学习挑战赛】顺序查找和二分查找的小总结
An overview of the most useful DeFi tools
els block deformation judgment.
Kunpeng compile and debug plug-in actual combat
07-SDRAM :FIFO控制模块
go语言标准库fmt包怎么使用
TCL:在Quartus中使用tcl脚本语言进行管脚约束
JSP 如何获取request对象中的路径信息呢?
MYSQL(基本篇)——一篇文章带你走进MYSQL的奇妙世界






