JavaFX BorderPane vs Pane hiding Labels

336 Views Asked by At

I have a working map using Pane and Path and Label objects. I place several Path and Label objects onto the Pane. The Path objects represent countries and the Label objects their capitals. So it shows a country and in the middle a Label with a String object bound to the Label.

count.textProperty().bind(system.getNations().get(nameNoSpace).getTroopCount().asString());

When using BorderPane instead of Pane the Label objects suddenly stop showing up?

Any idea what is the reason ?
Is the BorderPane hiding the Labels ?

Thanks

1

There are 1 best solutions below

1
On BEST ANSWER

You cannot add children to a BorderPane using the root.getChildren().add(node) method. to add object to a BorderPane you need to use other methods such as

setCenter(node);
setTop(node);
setBottom(node);
setLeft(node);
setRight(node);

See the BorderPane documentation for more informations.

If you need to use thegetChildren().add() method you can insert a Pane at the center of the BorderPane and add the nations in the Pane.