当前位置:网站首页>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);//把滚动条显示到控制面板上
边栏推荐
- Grid false data injection attacks detection based on coding strategy
- Knowing the inorder traversal of the array and the preorder traversal of the array, return the postorder history array
- 短视频seo搜索优化主要内容
- 重装腾讯云云监控后如果对应服务不存在可通过sc.exe命令添加服务
- 工业信息物理系统攻击检测增强模型
- How to find new potential projects?Tools recommended
- 实现删除-一个字符串中的指定字母,如:字符串“abcd”,删除其中的”a”字母,剩余”bcd”,也可以传递多个需要删除的字符,传递”ab”也可以做到删除”ab”,剩余”cd”。
- Double queue implementation stack?Dual stack implementation queue?
- 构造方法,this关键字,方法的重载,局部变量与成员变量
- DFS详解
猜你喜欢

These 4 computer notepad software, you have to try

Graphical LeetCode - 1161. Maximum Sum of In-Layer Elements (Difficulty: Moderate)

实现删除-一个字符串中的指定字母,如:字符串“abcd”,删除其中的”a”字母,剩余”bcd”,也可以传递多个需要删除的字符,传递”ab”也可以做到删除”ab”,剩余”cd”。

Redis - message publish and subscribe

测试用例:四步测试设计法

Collection of NFT tools

PHP to read data from TXT file

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

一文概览最实用的 DeFi 工具

146. LRU cache
随机推荐
基于相关性变量筛选偏最小二乘回归的多维相关时间序列建模方法
路由策略
MySQL常用语句整理
07-SDRAM :FIFO控制模块
poker question
PHP从txt文件中读取数据的方法
不了解SynchronousQueue?那ArrayBlockingQueue和LinkedBlockingQueue不会也不知道吧?
【21天学习挑战赛】顺序查找和二分查找的小总结
bgp 聚合 反射器 联邦实验
Unknown CMake command “add_action_files“
Routing strategy
以交易为生是一种什么体验?
Active Disturbance Rejection Control of Substation Inspection Robot Based on Data Drive
JSP out. The write () method has what function?
这 4 款电脑记事本软件,得试试
Multidimensional Correlation Time Series Modeling Method Based on Screening Partial Least Squares Regression of Correlation Variables
CRS 管理与维护
BGP first experiment
How does JSP use request to get the real IP of the current visitor?
How to design a circular queue?Come and learn~