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 Joonis6 extends Application { Foorituli tuli1; Foorituli tuli2; Button nupp1=new Button("kustuta"); Button nupp2=new Button("syyta"); Button knupp1=new Button("kustuta"); Button knupp2=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); tuli2=new Foorituli(Color.YELLOW, 50, 80, gc); tuli2.uusSeisund(1); nupud=new VBox(); nupud.getChildren().addAll(nupp1, nupp2, knupp1, knupp2); 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); }); knupp1.setOnAction((event) -> {tuli2.uusSeisund(0);}); knupp2.setOnAction((event) -> {tuli2.uusSeisund(1);}); //Pange teise nupu abil tuli taas põlema } }