Java 将多个JGoodies FormLayouts的列宽对齐

Java 将多个JGoodies FormLayouts的列宽对齐,java,layout-manager,jgoodies,form-layout,Java,Layout Manager,Jgoodies,Form Layout,使用JGoodies FormLayout: 我有一个面板,包含一个称呼、一个名字和一个名字。让我们称之为NamePanel,我现在想构建另一个包含第一个面板并添加更多行的面板。我们称之为NamedDressPanel NamePanel的布局如下所示: Salutation | textfield Name | textfield ForeName | textfield NamePanel Street | textfield Streetnumber

使用JGoodies FormLayout:

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

Salutation | textfield

Name       | textfield

ForeName   | textfield
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
因此,较大的面板通过将较小的名称面板放入其中并在其下方再放置几行来构建自身。 所以它的结构是这样的:

Salutation | textfield

Name       | textfield

ForeName   | textfield
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
现在,这个问题的结果如下所示:

Salutation | textfield

Name       | textfield

ForeName   | textfield
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
我希望它看起来像这样:

Salutation | textfield

Name       | textfield

ForeName   | textfield
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和NamedDressPanel使用FormLayout的两个不同实例

我目前唯一的解决方案是为标签列使用固定宽度,该宽度在所有面板中都相同。但是,当我添加一个恰巧太长的标签文本时,这显然是非常容易的

我能想到的另一种方法是以某种方式使用相同的布局,但我想像这样分割面板,使它们可重用。也就是说,我第一次把它作为一个单独的面板,但是我把它分开了,因为我需要在另一个地方放置名称面板本身


我可以告诉一个FormLayout与另一个FormLayout协商列宽吗?基本上与setColumGroups相似,但有多个FormLayouts?

类似的问题已经得到了回答:谢谢,很遗憾,似乎没有非黑客方式可以做到这一点:(