import javafx.application.Application; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.canvas.Canvas; import javafx.scene.canvas.GraphicsContext; import javafx.scene.control.Button; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.scene.shape.ArcType; import javafx.stage.Stage; public class Joonis5 extends Application { Foorituli tuli1; Button nupp1=new Button("kustuta"); Button nupp2=new Button("syyta"); VBox nupud; public static void main(String[] args) { launch(args); } @Override public void start(Stage stage) { stage.setTitle("Joonistusaken"); Group root = new Group(); Canvas canvas = new Canvas(300, 250); GraphicsContext gc = canvas.getGraphicsContext2D(); tuli1=new Foorituli(Color.RED, 50, 30, gc); tuli1.uusSeisund(1); nupud=new VBox(); nupud.getChildren().addAll(nupp1, nupp2); root.getChildren().add(canvas); root.getChildren().add(nupud); stage.setScene(new Scene(root)); stage.show(); nupp1.setOnAction((event) -> { System.out.println("Esimese nupu vajutus"); tuli1.uusSeisund(0); }); nupp2.setOnAction((event) -> { System.out.println("Teise nupu vajutus"); tuli1.uusSeisund(1); }); //Pange teise nupu abil tuli taas põlema } }