如何减少GridLayout中JCheckboxes之间的空间 [英] How to reduce space between JCheckboxes in GridLayout
问题描述
我在列中有三个Java JCheckboxes,通过将容器JPanel的布局设置为GridLayout(3,1,1,1)来排列。当我运行程序时,在JCheckBoxes之间有太多的垂直空间;它看起来像超过1个像素。由于我已经在布局中的JCheckboxes之间的垂直空间为1像素,那么我如何能减少这些JCheckbox之间的垂直空间呢?
I have three Java JCheckboxes in a column, arranged by setting the layout of the container JPanel to GridLayout(3, 1, 1, 1). When I run the program, there is too much vertical space between the JCheckBoxes; it looks like more than 1 pixel. Since I've already set the vertical space between the JCheckboxes in the layout to be 1 pixel, how else can I reduce the vertical space between these JCheckboxes?
谢谢。 / p>
Thanks.
推荐答案
如果您设置了复选框的边框,它会有帮助吗?
Does it help if you set the checkbox's border?
JCheckBox checkBox = new JCheckBox();
checkBox.setBorder(BorderFactory.createEmptyBorder());
这也可能是由于Look&感觉UI代表的渲染。你通常对这个没有什么控制。
It may also be due to the Look & Feel's UI delegate's rendering. You typically have little control over this.
这篇关于如何减少GridLayout中JCheckboxes之间的空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!