kevinxia
kevinxia

Reputation: 58

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?

Upvotes: 0

Views: 591

Answers (1)

A. Cucci
A. Cucci

Reputation: 180

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.

Upvotes: 2

Related Questions