Reputation: 4781
I am unable to find a way to set the distance to the border in a GridPane. Now, the text starts immediately after the border stops, which is not very nice for the design. I could give all the children a padding, but I was thinking there must be a shorter way to do this (just some property of the GridPane).
Unfortunately, I was not able to find this anywhere online. I prefer a solution which uses FXML or CSS (preferably CSS), but if this must be done with some Java code, it is not a problem.
I have already tried:
#someGridPane { -fx-border-insets: 5; }
, but these insets are outside the border (and I want them inside).So the question is: How to set the distance to the border in a GridPane?
Notes:
Upvotes: 2
Views: 1797
Reputation: 3010
There is a simpler, more natural solution:
GridPane {
-fx-padding: 5;
-fx-hgap: 5;
-fx-vgap: 5;
}
It does the same as using GridPane.setHgap(5)
etc, but with CSS.
Upvotes: 1
Reputation: 10989
Depending on what's in your grid pane you could cheat a bit.
GridPane > Text {-fx-translate-x : 5;}
GridPane > Label {-fx-label-padding: 0 0 0 5;}
Of course, add some style class names, but you get the idea.
Upvotes: 2