2

Using JGoodies FormLayout:

I have a Panel that contains a Salutation, a name and a forename. Let's call it NamePanel I now want to build another Panel that contains the first Panel and adds a few more rows. Let's call it NamedAddressPanel The layout of NamePanel looks like this:

Salutation | textfield

Name       | textfield

ForeName   | textfield

So the bigger Panel builds itself by putting the small NamePanel in it and puts a few more rows below it. So it builds itself like this:

NamePanel

Street       | textfield 

Streetnumber | textfield

Now the problematic result of this looks like this:

Salutation | textfield

Name       | textfield

ForeName   | textfield


Street       | textfield 

Streetnumber | textfield

I want it to look like this:

Salutation   | textfield

Name         | textfield

ForeName     | textfield


Street       | textfield 

Streetnumber | textfield

The labels in the NamePanel will have a different width than the ones added below it in the NamedAddressPanel. They won't align with each other correctly because the NamePanel and the NamedAddressPanel use 2 different instances of FormLayout.

My only solution to this currently is to use a fix width for the label column that is the same in all Panels. But that obviously breaks pretty easy when I add a label text that happens to be too long.

The single other way I can think of is to somehow use the same Layout, but I want to split up Panels like this to make them reusable. I.e. I first had this as a single Panel but split it up because I need the NamePanel itself in one more place.

Can I somehow tell a FormLayout to negotiate a column width with another FormLayout? Basically like setColumGroups but with multiple FormLayouts?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Cola Colin
  • 233
  • 1
  • 2
  • 10

0 Answers0