JavaFX Canvas GraphicsContext draw round rectangle
import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.canvas.Canvas; import javafx.scene.canvas.GraphicsContext; import javafx.scene.layout.Pane; import javafx.stage.Stage; public class Main extends Application { public static void main(String[] args) { Application.launch(args);/*from www . j a va2s .c o m*/ } @Override public void start(Stage stage) { // Create a canvas Canvas canvas = new Canvas(300, 100); // Get the graphics context of the canvas GraphicsContext gc = canvas.getGraphicsContext2D(); // Draw a rounded rectangle gc.strokeRoundRect(10, 10, 50, 50, 10, 10); Pane root = new Pane(); root.getChildren().add(canvas); Scene scene = new Scene(root); stage.setScene(scene); stage.setTitle("Drawing on a Canvas"); stage.show(); } }