Remove particular node in border pane in javafx - java

I have a border pane and there are components in its top, left and right side. I want to remove the components of its right side by using id of the borderPane through a mouse event. How do I do that?

Just do
borderPane.setRight(null);

Related

JavaFX layout moves when button is clicked

This is a gif of my problem:
As you can see, the button resizes (elevates? and it moves it's outer layout with itself.
This is the hierarchy:
StackPane
Group // for other content
Group // The make hbox "wrap-content"
HBox // For the 2 buttons
JfxToggleButton // "This is test"
JfxButton // "Restart" button
The only code to add is that I am positioning the HBox's Group top right of the StackPane, like this:
StackPane.setAlignment(hboxGroup, Pos.TOP_RIGHT)
Only StackPane has this issue, BorderPane does not have it.
The reason I am using StackPane is because I want to have the controls on top of the main content.
ToggleButton and HBox have padding.
Actually, padding and alignment do not matter, since the HBox moves relatively regardless.
Btw, I am using jfonix library for button styling.
Thanks for your help.
Edit.:
For those who contribute this problem to JFoenix, this is the same with standard JavaFX controls: (the jump still occurs, only less noticable)
Compared to what I mentioned above, where theHboxhas it's place in the top of a BorderPane, the jump does not happen:
I realized AnchorPane does not have this problem.
So this the final layout hierarchy:
StackPane
Group // Content behind
AnchorPane // That restricts movement, keeps the buttons in place
Group // That keeps the background only around the buttons
HBox // Keeps the buttons next to each other
ToggleButton
Button
So I ended up with the problem that AnchorPane does not let clicks through. Which is fixed by setting the AnchorPane
anchorPane.setPickOnBounds(false);

How do you lock a button's position in JavaFX?

In one of my javafx projects I have a button that triggers the program. Upon displaying new data sometimes the button is pushed downwards due to other components of the borderpane expanding. Any way I can lock the button to a specific position so that it does not move if that occurs?
You could try placing the button on a separate Pane outside of the BorderPane, then grouping both Panes on a root Pane/main Pane of some sort, like so:
Any layout changes to child components of the BorderPane will not affect the layout of any components outside of it.
As you can see though, this leaves empty space at the top of the application. You can overlap the StackPane with the Button on top of the BorderPane if you fiddle with its layout settings, but this does mean that any child components of the BorderPane can be hidden behind the StackPane. It's up to you to decide which way you prefer.

java align an HBox to the bottom left

I dont want to use a gridpane.
So I have an HBox:
HBox fooBar = new HBox();
fooBar.setHeight(100);
fooBar.setWidth(100);
fooBar.setAlignment(pos.BOTTOM_LEFT);
I gave it a color in css.
I include it into my scene and for some reason the box stays stuck on the bottom left corner. Is there any way to position it?
I forgot to mention: this hbox is the child of another hbox where I didnt define any position or dimension.
Hbox is a component which determine position own children. If you want change position you should change alignment property in parent. It impact for all children. You couldn't change position for one child. All children have to be obedient.
You can use Pane for absolute positioning.

Add a Label inside the border of an HBox or a VBox

I would like to add a Label - i.e. some text inside the border of a JavaFX HBox. The text should sit in the top left corner of the HBox and be inside the visible border area. I used to be able to do this in Swing, but I haven't figured out how to do it in JavaFX.
Thanks

How to align background component of a pane to the right?

I have a component "graphEditorPane" which extends from JGraph. Now I have this code :
graphEditorPane.setBackgroundComponent(situationLabel);
the problem is that this situationLabel is always aligned to the top left at the background of the pane. Is there a way to set it at the center of(the background of) the pane?

Categories