2

DefaultFormBuilder has been deprecated in version of JGoodies 1.9.0. The suggested alternative is FormBuilder.

Old code using DefaultFormBuilder:

builder.appendSeparator("Autoset");
builder.append(description);
builder.nextLine();

New code using FormBuilder:

builder.addSeparator("Autoset").xy(1, 1);
builder.add(description).xy(1, 3);

Note that the positions of the added elements have to be explicitly given. Is this really necessary? Is there any equivalent of append() (without coordinates) and nextLine()?

koppor
  • 19,079
  • 15
  • 119
  • 161

1 Answers1

2

I've found that the DefaultFormBuilder has been widely abused in the projects I worked in. It was intended for very simple forms only. Often developers have added cursor operations that ended up in code that is hard to read - and needs two passes to understand the overall layout.

Therefore it has been deprecated.

The FormBuilder code should read:

FormBuilder.create()
.columns("...")
.rows("...")
.addSeparator("Autoset").xy(1, 1)
.add(description) .xy(1, 3)
.build();

  • My issue is that I don't care of the real Y position. I just want to add lines and JGoodies calculates the concrete coordinates by itself. Introducing `y` as variable and doing `y++` inbetween is IMHO also not good code, is it? - Maybe, this is the wrong place to discuss this. – koppor Jan 14 '16 at 15:08