I know that elements in Flow Pane layout in JavaFX are positioned next each other in one orientation. I want in the middle of this process to force JavaFX to put elements in a new line , to some extend like "\n" character in print method . How i can do this ?
Asked
Active
Viewed 4,066 times
2
-
1`FlowPane` doesn't have that functionality. Why not put multiple `FlowPane`s in a `VBox`? – James_D May 08 '17 at 12:20
-
@James_D you should add this as an answer. I have not noticed your comment when looking for a solution and had to come up with it myself (which took some time) – Martin Stangel Aug 13 '19 at 14:48
2 Answers
3
A blank full width node behaves like "\n" in FlowPane
.
Region p = new Region();
p.setPrefSize(Double.MAX_VALUE, 0.0);
flowPane.getChildren().add(p);
I think this is effective in case you want to control line breaking as a node.

monolith52
- 886
- 2
- 6
- 9
2
That isn't how FlowPane works. You may be better off using a GridPane so you can specify the number of rows/columns. Or you can use a composite layout and use a FlowPane for each row, then put all your FlowPanes in a VBox.

Michael
- 2,683
- 28
- 30