Home > Mobile >  How create Indent for letters in button. JavaFX
How create Indent for letters in button. JavaFX

Time:01-06

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.

CodePudding user response:

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);
  • Related