How create Indent for letters in button. JavaFX

107 Views Asked by At

I have standard button and me need create indent for letters in this button, how it do? Sorry behind my English..

I had tried find in documentation JavaFX CSS the decision but him not or i him no find. Example how should to look like text in button: T e x t.

1

There are 1 best solutions below

2
On BEST ANSWER

You can do something like the following:

final int spacing = 8; // pixels between each letter
final String buttonText = "Text"; // text to display
Button button = new Button();
HBox graphic = new HBox(spacing);
for (int i=0; i<buttonText.length(); i++) {
    graphic.getChildren().add(new Label(buttonText.substring(i, i+1)));
}
button.setGraphic(graphic);