gpt4 book ai didi

java - 在交替列 GridBagLayout 中设置组件

转载 作者:行者123 更新时间:2023-12-01 20:51:55 26 4
gpt4 key购买 nike

有没有办法使用 GridBagConstraints 在交替的 0、2、4、6 列中设置组件,而无需在 GridBagLayout 中使用空组件填充 1、3、5?

这里的 Java 示例将第 5 个按钮设置为从第 1 列开始,但可能是因为它上面的行已经设置了?
https://docs.oracle.com/javase/tutorial/uiswing/layout/gridbag.html

最佳答案

Is there a way to set components in alternating columns 0, 2, 4, 6 without filling 1, 3, 5 with an empty component in a GridBagLayout

没有。如果没有为单元定义组件,那么它的大小基本上为 0。

布局无法猜测您期望“空列”的大小。

也许您可以使用“insets”约束在列之间留出空间。

关于java - 在交替列 GridBagLayout 中设置组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43240363/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com