Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Lab 7- pg 624 #15.19
- import javafx.animation.PathTransition;
- import javafx.animation.Timeline;
- import javafx.application.Application;
- import javafx.scene.Scene;
- import javafx.scene.control.Label;
- import javafx.scene.layout.Pane;
- import javafx.scene.paint.Color;
- import javafx.scene.shape.Rectangle;
- import javafx.scene.text.Text;
- import javafx.scene.shape.Circle;
- import javafx.stage.Stage;
- import javafx.util.Duration;
- public class Lab7 extends Application {
- private int counter = 0;
- long starttime = System.currentTimeMillis();
- @Override // Override the start method in the Application class
- public void start(Stage primaryStage) {
- Pane pane = new Pane();
- Color rand = new Color(Math.random(), Math.random(), Math.random(), 1);
- Circle circle = new Circle(Math.random()*200, Math.random()*200, Math.random()*50);
- circle.setFill(rand);
- circle.setStroke(rand);
- circle.setRadius(10);
- pane.getChildren().add(circle);
- System.out.print(counter);
- if(counter == 20) {
- pane.getChildren().clear();
- long time = System.currentTimeMillis() - starttime;
- String length = Long.toString(time);
- Label timing = new Label("It took " +length + " milliseconds to complete the game.");
- pane.getChildren().add(timing);
- }
- circle.setOnMouseClicked(e ->start(primaryStage));
- counter ++;
- Scene scene = new Scene(pane, 300, 300);
- primaryStage.setTitle("Lab 7");
- primaryStage.setScene(scene);
- primaryStage.show();
- }
Add Comment
Please, Sign In to add comment