JavaFX: Wrapping The Label

This entry is part 17 of 55 in the series JavaFX

With label, we can wrap the text and set to display the text vertically.

package javafxapplication14;

import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.stage.Stage;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;

public class JavaFXApplication14 extends Application {

    public void start(Stage stage) {

        stage.setTitle("JavaFX Program!");

        StackPane stackpane = new StackPane();

        Scene scene = new Scene(stackpane, 500, 400);

        stackpane.setStyle("-fx-background-color: grey;");

        Label lb = new Label("Where The Street Has No Name");
        lb.setFont(Font.font("Times New Roman", 72));
        StackPane.setAlignment(lb, Pos.TOP_CENTER);

        Label lb1 = new Label("Hello");
        lb1.setFont(Font.font("Times New Roman", 52));
        StackPane.setAlignment(lb1, Pos.CENTER_RIGHT);

        stackpane.getChildren().addAll(lb, lb1);;

    public static void main(String[] args) {



Series Navigation<< JavaFX: Setting the margin
JavaFX: Calling Event Using Lambda Expression >>