import javafx.scene.paint.Color; 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 static javafx.application.Application.launch; /** * Use this template to create drawings in FX. Change the name of the class and * put your own name as author below. Change the size of the canvas and the * window title where marked and add your drawing code where marked. * * @author YOUR NAME */ public class CircleDisplay extends Application { /** * Start method (use this instead of main). * * @param stage The FX stage to draw on * @throws Exception */ @Override public void start(Stage stage) throws Exception { Group root = new Group(); Scene scene = new Scene(root); Canvas canvas = new Canvas(800, 700); // Set canvas Size in Pixels stage.setTitle("Circle Array"); // Set window title root.getChildren().add(canvas); stage.setScene(scene); GraphicsContext gc = canvas.getGraphicsContext2D(); // YOUR CODE STARTS HERE Circle[] a = new Circle[10]; for (int i = 0; i < a.length; i++){ double x1 = i * 60; double y1 = i * 50; Color thecolor = Color.rgb(getRandomInteger(0, 255),getRandomInteger(0, 255),getRandomInteger(0, 255)); a[i] = new Circle(30,thecolor, x1,y1); a[i].draw(gc); } // YOUR CODE STOPS HERE stage.show(); } /** * The actual main method that launches the app. * * @param args unused */ public static void main(String[] args) { launch(args); } /** Provides a random int between minimum and maximum,not including maximum @return minimum <= num < maximum */ public static int getRandomInteger( int minimum, int maximum) { return ((int) (Math.random() * (maximum - minimum))) + minimum; } } //Main