Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a JavaFX equivalent of JGoodies FormLayout and DefaultFormBuilder?

Currently I am in the progress of migrating a Swing application’s preferences panel to JavaFX. The application first reads what needs to be built off a xml file. Then the application uses that information to create and append a large number of JComponents and associated JLabels to the panel along with some separators as follows:

layout = new FormLayout(description, "");
builder = new DefaultFormBuilder(bottomLayout);

// In some loop
propertyControlImpl.layout(builder);

public void layout(final DefaultFormBuilder builder) {
    final JLabel label = builder.append(TextUtils.getOptionalText(getLabel()), component);
    // set the text property of label, etc
}

public void layout(final DefaultFormBuilder builder) {
    builder.appendSeparator(TextUtils.getOptionalText(getLabel()));
}

What would be the best approach for transforming this into JavaFX? Are there any open source JavaFX libraries that have been made for this? If not, I plan to use a combination of stacked TitlePanes and hboxes to place the various controls (components) in.

Here is a mock (created with JavaFX SceneBuilder) of what I am trying to generate. I have not aligned everything perfectly yet but I would like to have all the labels right justified and take up the space of the longest label. All the components to be left justified to the right of the labels (just like how the DefaultFormBuilder lays out things):

Mock

like image 563
Kent Shikama Avatar asked Mar 28 '14 15:03

Kent Shikama


2 Answers

The closest thing to what you are requesting that I have seen is FXForm2. It generates a form based on a POJO with JavaFX Bean properties. Perhaps not the most elegant or perfect for what you are looking for but might help you on your way.

like image 161
LinkXXI Avatar answered Sep 28 '22 06:09

LinkXXI


Although FXForm2 seemed to be an option, I ended up using ControlsFX's Property Sheet control. The CATEGORY mode for the property sheet was almost exactly what I was looking for. It includes a built-in search bar that I found very useful.

like image 20
Kent Shikama Avatar answered Sep 28 '22 05:09

Kent Shikama