Auto-size pane in JavaFX like scene builer have - javafx

I creating site builder and I want anchorpane at center of another pane. I have 3 anchor panes in SplitPane and in the central pane I need rezise of object like scene builder have when you resize scene builder. How to make that resizing? Is it very hard? I want to make this in fxml or directly in scene builder. I use IntelliJ.
This picture is show how it look when you open at first time and it need to be always 16:9 (central pane). Maybe you know what pane can be it
And this is how it look when you open in full-screen
In this example I tried to use borderPane and I put empty anchorpane's in all other corners because when you put something in center it fit all borderPane. How I remember when you do this thing in anchorPane with constraints (like 100px from upper corner) it looks the same.
How to do normal 16:9 all-time resizing?

Related

JavaFx Resizing imageview to fit the container Pane and set it on the center

I'm trying to make an imageview fit the size of its container (in my case a Pane), and at the same time place it in the center of the Pane in JavaFx, in detail I can't do both at the same time i can get it to fit the container, but not put it in the center.
here is the code i use to make it fit in the container Pane
//imgContainer is the pane that contains the image
//photo is my imageview
photo.fitWidthProperty().bind(imgContainer.widthProperty());
photo.fitHeightProperty().bind(imgContainer.heightProperty());
photo.setImage(new Image(post.getPhoto()));
this is the output that is produced, the photo adapts to the Pane dimensions, but it is located to the left of the container(the dark background is the Pane container) would to put it in the center of the pane and i couldn't find a method to do it keeping the dimensions of the Pane for the imageview, putting it on a hbox or stackPane allows to put it in the center but the image no longer keeps the container sizes well, so i don't know how to get it centered and fits the container at the same time

Problem fitting TilePane's height and width to parent ScrollPane in SceneBuilder

I'm building a JavaFX desktop app using scenebuilder for the UI.
Here i have a tilepane inside of a scrollpane, i couldnt use the "fit to parent" option from the context menu in scene builder, i guess the solution is to give them -fx-id's and bind their width in the controller ?
I dont want to use any values so it all comes together nice when the user resizes the window.
how should i go about doing this?

JavaFX Scenebuilder moving elements inside StackPane

I am trying to move things such as buttons and labels that I put inside a StackPane since I want these things to stay centered when minimizing or maximizing windows. When I put everything I want into the StackPane, they all get centered and layered up on each other. How am I able to move these elements around in the StackPane if it's possible or how will I be able to keep everything centered when resizing the window?
You edit their TranslateX and TranslateY properties. for instance
Label label1 = new Label();
label1.setText("0");
label1.TranslateX(-10.0); //<< moves the label 10 pixels to the left.
if you are using Scene Builder you can edit these properties on the right under the "layout" tab.

How To Center a GridPane on a Stage

Context: I'm currently writing an application using JavaFX. At the moment I've created a login form that is placed on a Scene within a GridPane, however currently the GridPane is always aligned in the top left corner of the application.
Problem: What I would like to do is center the login form (within a GridPane) into the middle of the window instead of the top left. How would I go about this? Would I need to place the GridPane within another layout and center it that way? Could I somehow designate the positioning of the GridPane using CSS?

How do you get a ScrollPane that is placed in the center of a BorderPane to work?

I have a program where i have a rootLayout made from a BorderPane. When i press a button in this rootLayout i place a new fxml view into the center of the the borderPane using .setCenter(). The view i am placing into the borderPane consists of an AnchorPane that has a scrollPane as it's child element and when i run this view by itself the scrolling works. However after placing the view into the borderPane it stops working. The area in the scrollPane doesnt move at all when i scroll down or up. I am guessing this has to do with the size that is given in the borderPane but the whole point of having the scrollPane is so that i can show all of the information in 1/3 of the space.
Any tips or Ideas on how to make this work in either javafx, fxml or scenebuilder?
Can't make comments yet ... correct me if I'm wrong but don't you have to use the AnchorPane as the child of the ScrollPane? I always have my TextAres as child of the ScrollPanes!

Resources