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):
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With