FontPosture class is a part of JavaFX. FontPosture class specifies whether a font is REGULAR or ITALIC. FontPosture class inherits Enum class.
Commonly Used Methods:
|findByName(String n)||Returns FontPosture by its name.|
|valueOf(String n)||Returns a FontPosture with the specified name.|
|values()||returns an array with all the elements of the FontPosture type.|
Java Program to create a font object and set a specified posture and apply it to a text: In this program we will create two Text object and set one’s font posture to REGULAR and the other one to ITALIC. Then set the text to the TextFlow and add this textflow to the VBox and add the vbox to the scene, and add the scene to the stage. Also, set the line spacing and text alignment of the textflow and the spacing of the vbox. Call the show() function to display the final results.
Note: The above programs might not run in an online IDE please use an offline compiler.
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.