This content has been marked as final. Show 2 replies
WHat you can do is using bindings. JavaFX relies a lot that (and it is very powerful). In your case it could be something that look like:
More information about properties and binding:
AnchorPane container = new AnchorPane(); Button button = new Button("Test button"); // Says that the button is 25% pixel from the left button.layoutXProperty().bind(container.widthProperty().multiply(0.25d)); // 47% from the top button.layoutYProperty().bind(container.heightProperty().multiply(0.47d)); container.getChildren().add(button);
Hope it helps
Thanks for the answer. I had not really considered bindings in a regular Pane to replace a custom Pane implementation but that seems logical. After grabbing the source for the AnchorPane I just extended the library version, and overrode the layoutChildren() method with the opensource version and replaced where it was grabbing the anchors. This worked really well for a two line code change proof of concept but the devil will be in the details (may be assuming too much) so it's always nice to have a plan B.