2

使用 JGoodies 表单布局:

我有一个包含称呼、名字和名字的面板。我们称它为 NamePanel 我现在想要构建另一个 Panel 包含第一个 Panel 并添加更多行。我们称它为 NamedAddressPanel NamePanel 的布局如下所示:

Salutation | textfield

Name       | textfield

ForeName   | textfield

因此,更大的面板通过将小的 NamePanel 放入其中并在其下方多放置几行来构建自己。所以它像这样构建自己:

NamePanel

Street       | textfield 

Streetnumber | textfield

现在这个有问题的结果看起来像这样:

Salutation | textfield

Name       | textfield

ForeName   | textfield


Street       | textfield 

Streetnumber | textfield

我希望它看起来像这样:

Salutation   | textfield

Name         | textfield

ForeName     | textfield


Street       | textfield 

Streetnumber | textfield

NamePanel 中的标签将具有与 NamedAddressPanel 中添加在其下方的标签不同的宽度。它们不会正确对齐,因为 NamePanel 和 NamedAddressPanel 使用 2 个不同的 FormLayout 实例。

我目前对此的唯一解决方案是为所有面板中相同的标签列使用固定宽度。但是,当我添加一个恰好太长的标签文本时,这显然很容易出错。

我能想到的另一种方法是以某种方式使用相同的布局,但我想像这样拆分面板以使其可重用。即,我首先将其作为一个单独的面板,但将其拆分,因为我需要将 NamePanel 本身放在另一个位置。

我可以以某种方式告诉 FormLayout 与另一个 FormLayout 协商列宽吗?基本上像 setColumGroups 但有多个 FormLayouts?

4

0 回答 0