import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.canvas.Canvas; import javafx.scene.canvas.GraphicsContext; import javafx.stage.Stage; import javafx.scene.control.Button; public class Joonis1 extends Application{ public static void main(String[] args) { launch(args); } MovingObject kujund=new Boat(); Button nupp1=new Button("liigu"); @Override public void start(Stage stage) { stage.setTitle("Joonistusaken"); Group root = new Group(); Canvas canvas = new Canvas(300, 250); GraphicsContext gc = canvas.getGraphicsContext2D(); root.getChildren().add(canvas); root.getChildren().add(nupp1); stage.setScene(new Scene(root)); stage.show(); kujund.setX(50); kujund.setY(30); kujund.setAngle(50); gc.fillOval(kujund.getX(), kujund.getY(), 20, 20); nupp1.setOnAction((event) -> { System.out.println("Esimese nupu vajutus"); kujund.move(5); gc.fillOval(kujund.getX(), kujund.getY(), 20, 20); }); } }