Farid Abdi
Farid Abdi

Reputation: 99

How to position elements in a new line in Flow Pane layout in JavaFX?

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 ?

Upvotes: 2

Views: 4388

Answers (2)

monolith52
monolith52

Reputation: 884

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.

Upvotes: 2

Michael
Michael

Reputation: 2726

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.

Upvotes: 1

Related Questions