J. Doe
J. Doe

Reputation: 79

JavaFX Button setFont

I am working on small JavaFX project. This time I want to change font of text shown on my buttons. I tried to do this like this:

Button button = new Button("Not formatted text");
Font font = new Font(40); //Button font's size should increase to 40
button.setFont(font);

but it simply doesn't work - size remains same as before. Also it looks like there is no simmilar method to achieve this. How to change font of text on JavaFX button? I know that this question looks kind of trivial, but, seriously, I spent almost 1,5h looking for this and I am giving up. Please, help me :(

Upvotes: 2

Views: 13965

Answers (1)

Umer Farooq
Umer Farooq

Reputation: 792

try

button.setStyle("-fx-font-size:40");

Upvotes: 7

Related Questions