Example usage for javafx.scene.canvas GraphicsContext strokeText

List of usage examples for javafx.scene.canvas GraphicsContext strokeText

Introduction

In this page you can find the example usage for javafx.scene.canvas GraphicsContext strokeText.

Prototype

public void strokeText(String text, double x, double y) 

Source Link

Document

Draws the given string of text at position x, y with the current stroke paint attribute.

Usage

From source file:Main.java

@Override
public void start(Stage stage) {
    Canvas canvas = new Canvas(300, 100);

    GraphicsContext gc = canvas.getGraphicsContext2D();

    gc.setLineWidth(2.0);//from  w w  w  .  jav a2 s. co  m
    gc.setFill(Color.RED);

    gc.strokeRoundRect(10, 10, 50, 50, 10, 10);

    gc.fillOval(70, 10, 50, 20);

    gc.strokeText("Hello Canvas", 150, 20);

    Pane root = new Pane();
    root.getChildren().add(canvas);
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.setTitle("");
    stage.show();
}