JavaFX: Change font and size in a TextField

15,098

Try like this way:

TextField tf = new TextField();
tf.setFont(Font.font("Verdana", FontWeight.BOLD, 70));

or for setting a custom font

tf.setFont(Font.loadFont("file:resources/fonts/isadoracyr.ttf", 120));

Ref: Using Text and Text Effects in JavaFX

Share:
15,098
David
Author by

David

Student in engineering in embedded electronic in France. Not very good at programming but still learning.

Updated on June 04, 2022

Comments

  • David
    David almost 2 years

    The default font settings in TextField depends on your Windows settings and when they are not the same I encounter display issues. So I want to set the TextField to a specific font and size but I don't know how to do it.
    Could you please help me on this ?

  • David
    David over 8 years
    Thanks I was trying this on my container instead of my TextField that is the reason why it didn't worked.