import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.stage.Stage;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;

public class ColorTest extends Application {
    public void start(Stage stage) {
        stage.setTitle("Color Test");

        final Canvas canvas = new Canvas(150, 100);
        GraphicsContext gc = canvas.getGraphicsContext2D();

        String msg = "Hello, World!";
        String family = "Times New Roman";
        gc.setFill(Color.BLUE);
        gc.setFont(Font.font(family, FontPosture.REGULAR, 18));
        gc.fillText(msg, 20, 25);
        gc.setFill(Color.ORANGE);
        gc.setFont(Font.font(family, FontPosture.ITALIC, 18));
        gc.fillText(msg, 20, 50);
        gc.setFill(Color.RED);
        gc.setFont(Font.font(family, FontWeight.BOLD, 18));
        gc.fillText(msg, 20, 75);

        Group root = new Group();
        root.getChildren().addAll(canvas);
        Scene scene = new Scene(root);
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String... args) {
        launch(args);
    }
}
