package test.scenegraph.app; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Group; import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.canvas.Canvas; import javafx.scene.canvas.GraphicsContext; import javafx.scene.control.Button; import javafx.scene.effect.BlendMode; import javafx.scene.layout.Pane; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.scene.shape.ArcType; import javafx.stage.Stage; public class ShortAppWithoutDependencies53 extends Application { public static void main(String[] args) { Application.launch(args); } @Override public void start(Stage stage) { Group root = new Group(); final Scene scene = new Scene(root, 600, 450); final VBox vb = new VBox(); vb.setLayoutX(10); vb.setLayoutY(10); vb.setSpacing(30); stage.setScene(scene); stage.show(); final Node node = drawNode(); final Button btnNext1 = new Button("do it again"); btnNext1.setOnAction(new EventHandler() { public void handle(ActionEvent t) { vb.getChildren().add(drawNode()); } }); vb.getChildren().add(btnNext1); vb.getChildren().add(node); ((Group) scene.getRoot()).getChildren().addAll(vb); } public Node drawNode() { Group group = new Group(); final Canvas canvas = new Canvas(70, 70); GraphicsContext gc = canvas.getGraphicsContext2D(); gc.stroke(); gc.setFill(Color.rgb(0, 50, 255)); gc.fillRect(10, 10, 35, 35); gc.setGlobalBlendMode(BlendMode.SOFT_LIGHT); gc.setFill(Color.rgb(255, 150, 0, 1)); gc.stroke(); gc.fillArc(20d, 20d, 45d, 45d, 20d, 360d, ArcType.ROUND); group.getChildren().add(canvas); return group; } }