当前位置:网站首页>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);//把滚动条显示到控制面板上
边栏推荐
猜你喜欢

Unknown CMake command “add_action_files“

Kunpeng compile and debug plug-in actual combat

Quick solution for infix to suffix and prefix expressions

IP核:FIFO

Short video SEO optimization tutorial Self-media SEO optimization skills and methods

DFS详解

146. LRU cache

An overview of the most useful DeFi tools

短视频SEO优化教程 自媒体SEO优化技巧方法

Arduino Basic Syntax
随机推荐
Quick solution for infix to suffix and prefix expressions
[Solution] Emqx startup under win10 reports Unable to load emulator DLL, node.db_role = EMQX_NODE__DB_ROLE = core
Collection of NFT tools
IO stream basics
Day11 shell脚本基础知识
Active Disturbance Rejection Control of Substation Inspection Robot Based on Data Drive
JSP page指令errorPage属性起什么作用呢?
微软电脑管家V2.1公测版正式发布
IP Core: FIFO
Redis - message publish and subscribe
JSP out.println()方法具有什么功能呢?
具有通信时延的多自主体系统时变参考输入的平均一致性跟踪
BGP first experiment
在不完全恢复、控制文件被创建或还原后,必须使用 RESETLOGS 打开数据库,解释 RESETLOGS.
bgp aggregation reflector federation experiment
基于数据驱动的变电站巡检机器人自抗扰控制
08-SDRAM: Summary
JSP built-in object out object function introduction
What is the function of the JSP out.println() method?
Unknown CMake command “add_action_files“