如何将滚动条添加到面板? [英] How to add scrollbar to panel?

查看:371
本文介绍了如何将滚动条添加到面板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要帮助。我有一个面板,可能需​​要宽1000px。我需要添加许多不同大小的按钮(我添加了流程布局,它工作正常)。问题是我在屏幕上有高度示例500px但是当我添加按钮面板时有更大的尺寸。如何将滚动条添加到面板?

I need help. I have one panel which can need to have width 1000px. I need to add lot of buttons with different size ( I add with flow layout and it works fine). Problem is that I have height on screen example 500px but when I add buttons panel has bigger size. How to add scrollbar to panel ?

推荐答案

将面板添加到滚动窗格并添加窗格而不是面板

Add your panel to scrollpane and add that pane where you are adding your panel instead of panel

JScrollPane jScrollPane = new JScrollPane(panel);

这篇关于如何将滚动条添加到面板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆