Pane always on top - JavaFX - java

My stage have as node, a boderpane with 2 childrens, one on top, one on bottom (like graphics for a game, on top big screen and on bottom the menu).
The idea is that the ''menu'' must be always on top.
Lets say screen size will be 500x400, top children will be 800x400 and bottom children will be 100x400.
I want that for user to be visible half-top side of topchildren and the bottom children.
I hope what I wrote is understandable.
Thank you!

Welcome to StackOverflow! Please be sure to have a little tour on how this site works by navigating to this link.
To achieve the gui design you are looking for, you may want to play with other built-in layout panes of JavaFX. My first suggestion is to use
[pseudo code]
<VBox>
<ScrollPane VBox.Vgrow="ALWAYS">
<Big screen pane/>
</ScrollPane>
<Menu pane/>
</VBox>
Second suggestion is to use AnchorPane where the "Menu pane" always snaps to bottom border of the stage.

Thank you for your concern.
I found answer.
I did not used borderpane as node for scene, but I used a simple pane.
I put both big gridpane and menu pane in same initial pane and i used
menuPane.relocate(0,360);
I also added a colored rectangle on the same coordonates but I assured to add menuPane as childern to initial pane, last one, to be in top of all.

Related

How to make a widget appear smoothly while keeping the anchor

I want to show a Pane whenever I click a button. The hard side is that I whant the pane to come out smootly for exemple by using a ScaleTransition from width=0 to width=100 but I whant my pane to be sticked to the side of the frame like you would normaly do with a widget inside an anchorPane.
I've tried to apply simutaniusly both a TranslateTranstion and a ScaleTransition. So the pane seems to expend to his right side. But one these transitions are done, the pane keeps its width and is not resized when the window is.
Slaw has answered my question in the comment section so I post his answer.
Would using TranslateTransition and a clip on the parent work for you? Just keep the child out of the clipped area, then translate it into the clipped area when you want to show it

How to Center Image and buttons/polygons?

Link to screenshots: https://imgur.com/a/uSpTG8I
First image is when the window is expanded, second one is when the program runs. The others is of the FXML file and the scenebuilder program.
I have looked this up and tried the various layout options in the scenebuilder program itself but none of them works as I wanted. I want the image to stay centered, and if possible, the arrow buttons to also be centered.
Thanks
I'm a fan of BorderPanes. If you wrap your arrows to the Center of the BorderPane they will stay centerd, even if you resize your Scene.
So if You want the arrows and the big Image Centered use a BorderPane and wrap the Image to the Center. Now you can wrap another BorderPane in parent BorderPane's Bottom and wrap your Arrows to center.

Free scroll pane (JavaFX)

What pane can I use to add anchorpanes(setting y and z).
Initially it is of a certain size, and if it is too many anchorpanes to show, i`d like to add a scroller with which I can scroll down the pane to see more elements.
P.S.
sry for my bad english
This Question is very simple to answer. Just use a Scroll Pane and a Element to group your Anchor-Panes, for example :
ScrollPane with VBox as Grouping
Or you can also use Frameworks for this like :
http://www.jfoenix.com/
http://fxexperience.com/controlsfx/
When I remember correctly, they designed a Pane which is automatically placing nodes like a Gallery. These nodes get moved when necessary.

How to create dual HBox using javafx

I am trying to make controls for a media player. I have a slider and volume control which i wish to sit above another row of controls such as play mute etc at the bottom of the window.
I thought a good way to achieve this was creating a HBox that sits above another HBox, both aligned to the bottom in a javafx application.
I tried to use insets and margins to offset one from the other but i was not able to get them both to show.
Another attempt was to add the two HBox nodes to a VBox to get them vertically placed, but that was not successful either (i don't think it can be done this way).
Does anyone know how to implement this? or is there a better way to achieve the desired effect?
A GridPane might be what your looking for.
It acts similar to HBox and VBox, such as you can get creative and add other grids and boxes inside the main grid.

JavaFx-- positioning components in SceneBuilder

I used the drag and drop interface to put the components where I want them to be, but when the window is resized they lose their relative position. I have attached a screen shot of my hierarchy and of two windows to show how the components lose their position.
Hierarchy
Fullscreen
If you want to use the AnchorPane to layout your components, you can set the Anchor Pane Constraints, like in the image below:
This way it doesn't matter if you resize the screen, the button will always stay 10px far from the AnchorPane's right border.
When you use the AnchorPane to place components on screen you are not going to have a relative positioning, You should use others containers to layout your application. Read more about how to use Layout Panes here: Using Layout Panes
You need to study how to use Layout Panes. Dragging and dropping components results in absolute positioning, which really bad practice.

Categories

Resources