JavaFX layout, a silver lining?
As described in the previous post, I believe that JavaFX’s layout mechanism is not as good as it could (should) have been. Naturally it is one thing to complain, another to offer improvement suggestions, but the best is to provide alternatives. First there is MigPane, which is a very powerful layout manager, but it is also possible to ‘slap’ on a different API onto existing layout managers. And that is what is being attempted in the JFXtra’s drop-in replacement layout managers. These layout managers extend the existing one, but add a different style.
The basic idea is that instead of writing:
VBox lVBox = new VBox(5.0); Button b1 = new Button("short"); lVBox.getChildren().add(b1); VBox.setVgrow(b1, Priority.ALWAYS);
You can write:
VBox lVBox = new VBox(5.0); lVBox.add(new Button("short"), new VBox.C().vgrow(Priority.ALWAYS));