JavaFX CubicCurve class

Description

JavaFX CubicCurve class

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.CubicCurve;
import javafx.scene.shape.StrokeType;
import javafx.stage.Stage;

public class Main extends Application {

    public static void main(String[] args) {
        Application.launch(args);/*from   w  ww  . j  a v a  2  s .com*/
    }
    
    @Override
    public void start(Stage primaryStage) {
        primaryStage.setTitle("java2s.com");
        Group root = new Group();
        Scene scene = new Scene(root, 300, 150, Color.WHITE);

        // CubicCurve
        CubicCurve cubicCurve = new CubicCurve();
        cubicCurve.setStartX(50);
        cubicCurve.setStartY(75);
        cubicCurve.setControlX1(80);
        cubicCurve.setControlY1(-25);
        cubicCurve.setControlX2(110);
        cubicCurve.setControlY2(175);  // control pt2
        cubicCurve.setEndX(140);
        cubicCurve.setEndY(75);// end pt (x2,y2)
        cubicCurve.setStrokeType(StrokeType.CENTERED);
        cubicCurve.setStrokeWidth(1);
        cubicCurve.setStroke(Color.BLACK);
        cubicCurve.setStrokeWidth(3);
        cubicCurve.setFill(Color.WHITE);
        root.getChildren().add(cubicCurve);

          primaryStage.setScene(scene);
        primaryStage.show();
    }
}



PreviousNext

Related