Hi, I have a javafx application, its basically that game with tiles that makes a picture (But I'm doing it with movies).
So basically, in the
public void start(Stage primaryStage) method:
Board board = new Board(); [ THIS EXTENDS GROUP, AND HAS LOTS OF MEDIAVIEWS ADDED TO ITS CHILDREN]
Group root = new Group();
Scene scene = new Scene(root)
So basically, I want the scene to fit perfectly around the board, I think I have to use binding somehow,
but I'm being overwhelmed with code when I try to read the javafx api, and I'm not getting anywhere by just playing around with it.
Also, if the boards children get bigger or smaller, I'd like the scene to adjust its size, so it still fits nicely.
Can anyone help?
You can find out the Window (Stage) a node is in with node.getScene().getWindow().
You can resize a Window to fit the preferred size of its scene with window.sizeToScene().
Maybe that can help with your problem.
I'm not experienced with the Group element, but from the API I see:
-->A Group will take on the collective bounds of its children and is not directly resizable.
Why not making use of a StackPane as parent element, and instead of extending from Group, extend from a Tile Pane or a Flow Pane?
Those containers resizes easelly. Don't forget to set the Max Width and Max Height to MAX_VALUE!
Hope this helps..
Marvellous, I put the sizeToScene() method in the board class, just after the Tiles are added, and it works.
Thanks for that, it was critical part of my program.
I just need to get my MenuBar to stretch across the size of the window, there's currently a big gap to the right of the FileMenu,
I'm not too sure how to do it.