Search code examples
javajavafxhtml-tablegridpane

gridpane javafx node column span how to use?


hey i have a gridpane and for one of the nodes i want it to be able to take up the whole row.

but i cant seem to figure out how to use GridPane.setColumnSpan(node, column span);

heres my code

grid.getChildren().addAll(animalFields(animal));
        grid.setHgap(10);
        grid.addRow(2, status, neutered, chipped, vaccinated, reserved);
        grid.addRow(3, statusCb,new HBox(neuteredYes, neuteredNo), new HBox(chippedYes, chippedNo), new HBox(vaccinatedYes, vaccinatedNo), new HBox(reservedYes, reservedNo));
        grid.addRow(4, new Label("people interested"));
        grid.addRow(6, sponsorsTable(((Adoption) animal.getAdoption()).getInterested()));
        GridPane.setColumnSpan(sponsorsTable(((Adoption) animal.getAdoption()).getInterested()), 6);
        grid.addRow(7, hBox2);

this is how it looks now

Current look

this is what i want it to look like

enter image description here

id be grateful for any help. thanks


Solution

  • You can use GridPane.REMAINING:

    GridPane.setColumnSpan(yourNode, GridPane.REMAINING);