2

I have a GridPane looks like the following:

enter image description here

I want to merge 3 columns in the center of the grid through code, but I can not find the way ho to do this. There is a reference how to achieve this through scene builder, but I don't use scene builder.

Does anyone have an idea how to merge them ?

2 Answers2

8

Use GridPane.setColumnSpan or use the appropriate GridPane.add method to add the Slider:

GridPane.setColumnSpan(slider, 3);

or

gridPane.add(slider, 0, 0, 3, 1);
fabian
  • 80,457
  • 12
  • 86
  • 114
2

The answer was covered before but the params was not clear for me, so I have add it here

gridPane.add(pane, 0, 0, 3, 1);

this will span 3 cell in the first row

gridPane.add(Node, columnIndex, rowIndex, colspan, rowspan);
Vasil Valchev
  • 5,701
  • 2
  • 34
  • 39