简体   繁体   中英

How create Indent for letters in button. JavaFX

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 ex t.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM