0

我有两个组件 C1 和 c2,我希望 C1 获得所需的水平空间,然后 C2 应该增长并占用剩余的水平空间,但是 c1 被赋予了太多的空间,如下所示:

在此处输入图像描述

我想要它,以便按钮的绿色边框边缘和红色边框之间没有空间。

我布置组件的代码如下:(c1 是 ProposalButtons)(c2 是 scrollBox)

this.setLayout(new MigLayout("insets 2, debug, fill"));
this.propositionalButtons = new PropositionalButtons(this.controller);
this.add(propositionalButtons, "top");

this.scrollBox = new JScrollPane();
this.scrollBox.setBorder(BorderFactory.createLineBorder(Color.green));
this.add(scrollBox, "grow");

this.setBackground(Color.BLUE);

任何帮助将不胜感激!谢谢。

4

1 回答 1

0

我手边没有编译器,但请尝试:

new MigLayout("insets 2, debug, fill", "[][grow]")

这将允许您的第二列增长。目前,您的所有列都没有设置为增长,因此空间分布在所有列中。MiG 布局不够聪明,无法将组件约束级联到行/列级别。

于 2013-04-25T15:24:26.507 回答