RazorBlade57

Lab 7

Apr 8th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.56 KB | None | 0 0
  1. //Lab 7- pg 624 #15.19
  2.  
  3.  
  4. import javafx.animation.PathTransition;
  5. import javafx.animation.Timeline;
  6. import javafx.application.Application;
  7. import javafx.scene.Scene;
  8. import javafx.scene.control.Label;
  9. import javafx.scene.layout.Pane;
  10. import javafx.scene.paint.Color;
  11. import javafx.scene.shape.Rectangle;
  12. import javafx.scene.text.Text;
  13. import javafx.scene.shape.Circle;
  14. import javafx.stage.Stage;
  15. import javafx.util.Duration;
  16.  
  17. public class Lab7 extends Application {
  18.   private int counter = 0;
  19.   long starttime = System.currentTimeMillis();
  20.  
  21. @Override // Override the start method in the Application class
  22.  
  23.   public void start(Stage primaryStage) {
  24.  
  25.     Pane pane = new Pane();
  26.    
  27.    
  28.     Color rand = new Color(Math.random(), Math.random(), Math.random(), 1);
  29.  
  30.     Circle circle = new Circle(Math.random()*200, Math.random()*200, Math.random()*50);
  31.     circle.setFill(rand);
  32.     circle.setStroke(rand);
  33.     circle.setRadius(10);
  34.    
  35.     pane.getChildren().add(circle);
  36.  
  37.  
  38.    
  39.     System.out.print(counter);
  40.    
  41.     if(counter == 20) {
  42.         pane.getChildren().clear();
  43.         long time = System.currentTimeMillis() - starttime;
  44.         String length = Long.toString(time);
  45.         Label timing = new Label("It took " +length + " milliseconds to complete the game.");
  46.         pane.getChildren().add(timing);
  47.     }
  48.    
  49.    
  50.     circle.setOnMouseClicked(e ->start(primaryStage));
  51.     counter ++;
  52.  
  53.     Scene scene = new Scene(pane, 300, 300);
  54.     primaryStage.setTitle("Lab 7");
  55.     primaryStage.setScene(scene);
  56.     primaryStage.show();
  57.   }
Add Comment
Please, Sign In to add comment