JavaFX | FontPosture Class Last Updated : 18 Sep, 2018 Comments Improve Suggest changes Like Article Like Report 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: Method Explanation 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. Java // Java Program to create a font object and set // a specified posture and apply it to a text import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.control.*; import javafx.scene.layout.*; import javafx.stage.Stage; import javafx.scene.layout.*; import javafx.scene.paint.*; import javafx.scene.text.*; import javafx.geometry.*; import javafx.scene.layout.*; import javafx.scene.shape.*; public class FontPosture_1 extends Application { // launch the application public void start(Stage stage) { try { // set title for the stage stage.setTitle("FontPosture"); // create TextFlow TextFlow text_flow = new TextFlow(); // create text Text text_1 = new Text("GeeksforGeeks\n"); // set the text color text_1.setFill(Color.GREEN); // create a font Font font = Font.font("Verdana", FontWeight.EXTRA_BOLD, FontPosture.REGULAR, 25); // set font of the text text_1.setFont(font); // create text Text text_2 = new Text("A Computer Science portal for geeks\n"); // set the text color text_2.setFill(Color.GREEN); // create a font Font font1 = Font.font("Verdana", FontWeight.EXTRA_BOLD, FontPosture.ITALIC, 12); // set font of the text text_2.setFont(font1); // set text text_flow.getChildren().add(text_1); text_flow.getChildren().add(text_2); // set line spacing text_flow.setLineSpacing(20.0f); // set text alignment text_flow.setTextAlignment(TextAlignment.CENTER); // create VBox VBox vbox = new VBox(text_flow); // set alignment of vbox vbox.setAlignment(Pos.CENTER); // create a scene Scene scene = new Scene(vbox, 400, 300); // set the scene stage.setScene(scene); stage.show(); } catch (Exception e) { System.out.println(e.getMessage()); } } // Main Method public static void main(String args[]) { // launch the application launch(args); } } Output: Note: The above programs might not run in an online IDE please use an offline compiler. Reference: https://docs.oracle.com/javase/8/javafx/api/javafx/scene/text/FontPosture.html Create Quiz Comment A andrew1234 Follow 0 Improve A andrew1234 Follow 0 Improve Article Tags : Java JavaFX Explore Java BasicsIntroduction to Java3 min readJava Programming Basics9 min readJava Methods6 min readAccess Modifiers in Java4 min readArrays in Java7 min readJava Strings7 min readRegular Expressions in Java3 min readOOP & InterfacesClasses and Objects in Java5 min readAccess Modifiers in Java4 min readJava Constructors4 min readJava OOP(Object Oriented Programming) Concepts10 min readJava Packages2 min readJava Interface7 min readCollectionsCollections in Java12 min readCollections Class in Java13 min readCollection Interface in Java4 min readIterator in Java4 min readJava Comparator Interface5 min readException HandlingJava Exception Handling6 min readJava Try Catch Block4 min readJava final, finally and finalize4 min readChained Exceptions in Java3 min readNull Pointer Exception in Java5 min readException Handling with Method Overriding in Java4 min readJava AdvancedJava Multithreading Tutorial3 min readSynchronization in Java7 min readFile Handling in Java4 min readJava Method References9 min readJava 8 Stream Tutorial7 min readJava Networking6 min readJDBC Tutorial5 min readJava Memory Management3 min readGarbage Collection in Java6 min readMemory Leaks in Java3 min readPractice JavaJava Interview Questions and Answers15+ min readJava Programs - Java Programming Examples7 min readJava Exercises - Basic to Advanced Java Practice Programs with Solutions5 min readJava Quiz1 min readJava Project Ideas For Beginners and Advanced15+ min read Like