import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.stage.Stage; import javafx.scene.text.Text; publicclassTextExample extends Application { @Override publicvoidstart(Stage stage){ //Creating a Text object Text text = newText(); //Setting the text to be added. text.setText("Hello how are you"); //setting the position of the text text.setX(50); text.setY(50); //Creating a Group object Group root = newGroup(text); //Creating a scene object Scene scene = newScene(root, 600, 300); //Setting title to the Stage stage.setTitle("Sample Application"); //Adding scene to the stage stage.setScene(scene); //Displaying the contents of the stage stage.show(); } publicstaticvoidmain(String args[]){ launch(args); } }
import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.stage.Stage; import javafx.scene.text.Font; import javafx.scene.text.FontPosture; import javafx.scene.text.FontWeight; import javafx.scene.text.Text; publicclass TextFontExample extends Application { @Override publicvoidstart(Stage stage) { //Creating a Textobject Texttext = new Text(); //Setting font to the text text.setFont(Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 20)); //setting the position of the text text.setX(50); text.setY(130); //Setting the textto be added. text.setText("Hi how are you"); //Creating a Groupobject Group root = newGroup(text); //Creating a scene object Scene scene = new Scene(root, 600, 300); //Setting title to the Stage stage.setTitle("Setting Font to the text"); //Adding scene to the stage stage.setScene(scene); //Displaying the contents of the stage stage.show(); } public static void main(String args[]){ launch(args); } }
import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.stage.Stage; import javafx.scene.text.Font; import javafx.scene.text.FontPosture; import javafx.scene.text.FontWeight; import javafx.scene.text.Text; publicclass StrokeExample extends Application { @Override publicvoidstart(Stage stage) { //Creating a Textobject Texttext = new Text(); //Setting font to the text text.setFont(Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 50)); //setting the position of the text text.setX(50); text.setY(130); //Setting the color text.setFill(Color.BROWN); //Setting the Stroke text.setStrokeWidth(2); // Setting the stroke color text.setStroke(Color.BLUE); //Setting the textto be added. text.setText("Hi how are you"); //Creating a Groupobject Group root = newGroup(text); //Creating a scene object Scene scene = new Scene(root, 600, 300); //Setting title to the Stage stage.setTitle("Setting font to the text"); //Adding scene to the stage stage.setScene(scene); //Displaying the contents of the stage stage.show(); } public static void main(String args[]){ launch(args); } }
import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.stage.Stage; import javafx.scene.text.Font; import javafx.scene.text.FontPosture; import javafx.scene.text.FontWeight; import javafx.scene.text.Text; publicclassDecorationsExample extends Application { @Override publicvoidstart(Stage stage){ //Creating a Text_Example object Text text1 = newText("Hi how are you"); //Setting font to the text text1.setFont(Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 20)); //setting the position of the text text1.setX(50); text1.setY(75); //Striking through the text text1.setStrikethrough(true); //Creating a Text_Example object Text text2 = newText("Welcome to Tutorialspoint"); //Setting font to the text text2.setFont(Font.font("verdana", FontWeight.BOLD, FontPosture.REGULAR, 20)); //setting the position of the text text2.setX(50); text2.setY(150); //underlining the text text2.setUnderline(true); //Creating a Group object Group root = newGroup(text1, text2); //Creating a scene object Scene scene = newScene(root, 600, 300); //Setting title to the Stage stage.setTitle("Decorations Example"); //Adding scene to the stage stage.setScene(scene); //Displaying the contents of the stage stage.show(); } publicstaticvoidmain(String args[]){ launch(args); } }