Text label = new Text(" " + labelText + " ");
label.setTextAlignment(TextAlignment.CENTER);
label.setFont(Font.font(null, bold ? FontWeight.BOLD : FontWeight.NORMAL, 10));
//position label accounting for width
label.relocate(labelX + labelWidth / 2 - label.getBoundsInLocal().getWidth() / 2, 0);
label.autosize();
if (leafPane.getChildren().isEmpty()) {
//just add first label
leafPane.getChildren().add(label);
} else {