将JPanel大小设置为以较小的边距填充父级 [英] Set the JPanel size to fill parent with little margin
问题描述
我有两个Jpanel( JpanelLeft 和 JpanelLeftContent )如何使JpanelLeftContent填充父级大小,左侧和右侧有一点边距。我尝试了不同的布局,并试图修改hgap和vgap值,但没有一个给我一个好的结果。
JPanel JpanelLeft = new JPanel();
JPanel JpanelLeftContent = new JPanel();
JpanelLeft.add(JpanelLeftContent);
如果可能的话,我如何使JpanelLeftContent看起来像一个圆角矩形,如图所示。 / p>
看一下 Border
的工作方式。特别是 BorderFactory.createEmptyBorder(int top,int left,int bottom,int right)
可能会有所帮助。
I have two Jpanel (JpanelLeft and JpanelLeftContent) how can i make the JpanelLeftContent fill parent size with a little margin on the left an right side. i have tried different layout and tried to modify the hgap and vgap values, but none of them give me a good result.
JPanel JpanelLeft = new JPanel();
JPanel JpanelLeftContent = new JPanel();
JpanelLeft.add(JpanelLeftContent);
And if possible how can i make the JpanelLeftContent look like a rounded rectangle as shown in the picture.
Take a look at how Border
s work. Especially BorderFactory.createEmptyBorder(int top, int left, int bottom, int right)
might be helpfull.
这篇关于将JPanel大小设置为以较小的边距填充父级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!