How to draw Polylines in JavaFX? [closed]

1

How do I draw Polylines on a canvas in JavaFX? I'm trying to do something similar:

public void start(Stage stage) {
        VBox box = new VBox();
        final Scene scene = new Scene(box, 300, 250);
        scene.setFill(null);

        double x=0.0,y=0.0;
        EventHandler filter = new EventHandler<InputEvent>() {
            @Override
            public void handle(InputEvent event) {
                     Line line = new Line();
        line.setStartX(0.0f);
        line.setStartY(0.0f);
        line.setEndX(100.0f);
        line.setEndY(100.0f);
        box.getChildren().add(line);


            }
        };
// Register the same filter for two different nodes
        scene.addEventFilter(MouseEvent.MOUSE_PRESSED, filter);

        stage.setScene(scene);
        stage.show();

    }

    public static void main(String[] args) {
        launch(args);
    }

But it accuses error that within events I can not use scene nor root nor any of these variables that I would give the exit of the polyline. Can someone help me ... or post a code using these data structures that I used (not to be so confused) .... thanks: D

    
asked by anonymous 29.06.2017 / 03:00

0 answers