I have made a login page in javafx. Problem is I want to change the font of prompt text in the textfields. I have tried passing the argument as type label and text but it wont accept anything except String. How would I do this ( without using css, hacks etc as m still a noob) ? I wish to change all of color, size as well as style.
How would i do this ?
At the moment, changing the style through Java API is not possible, but it will be available in the future releases of JavaFX framework. Currently you can set the style as string, think of an embedded CSS:
TextField textField = new TextField("Sample"); textField.setStyle("" + "-fx-font-size: 30px;" + "-fx-font-style: italic;" + "-fx-font-weight: bold;" + "-fx-font-family: fantasy;" + "-fx-text-fill: blue;" + "-fx-background-color: aqua");
The meaning of the atrribute and the values it can take are explained with their limitations in "JavaFX CSS Reference" guide. Refer to it and spend some time to grab the basic styling in JavaFX.