JavaFX SVGPath create

Description

JavaFX SVGPath create


import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.SVGPath;
import javafx.stage.Stage;

public class Main extends Application {
  public static void main(String[] args) {
    Application.launch(args);//from www  . j a v a 2  s  .c  o m
  }

  @Override
  public void start(Stage stage) {
    // Create a triangle using a SVGPath 
    SVGPath svgTriangle = new SVGPath(); 
    svgTriangle.setContent("M50, 0 L0, 50 L100, 50 Z"); 
    svgTriangle.setFill(Color.LIGHTGRAY); 
    svgTriangle.setStroke(Color.BLACK); 
    
    // Add all shapes to an HBox
    HBox root = new HBox(svgTriangle);
    root.setSpacing(10);

    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.setTitle("2D Shapes");
    stage.show();
  }
}



PreviousNext

Related