Help with javafx Create a javafx application that displays 1

Help with javafx: Create a javafx application that displays 1000 circles of random colors and at random locations each time the user clicks the pane. Make the scene 600w x 400h
Help with javafx: Create a javafx application that displays 1000 circles of random colors and at random locations each time the user clicks the pane. Make the scene 600w x 400h

Solution

import java.util.Random; import javafx.application.Application; import javafx.collections.ListChangeListener; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.paint.Color; import javafx.scene.shape.Circle; import javafx.stage.Stage; public class RandomColorTest extends Application { int radius = 20; int sceneWidth = 300; int sceneHeight = 300; @Override public void start(Stage primaryStage) throws Exception { Group root = new Group(); primaryStage.setResizable(false); primaryStage.setScene(new Scene(root, sceneWidth, sceneHeight)); final ObservableList ol = root.getChildren(); new Thread(new Runnable() { @Override public void run() { while (true) { try { // Wait for 2 seconds. Thread.sleep(2000); } catch (InterruptedException ex) { ex.printStackTrace(); } Platform.runLater(new Runnable() { @Override public void run() { System.out.println(\"ol size:\" + ol.size()); if (ol.size() == 5) { ol.remove(0); } ol.add(createCircle()); } }); } } }).start(); primaryStage.show(); }
 Help with javafx: Create a javafx application that displays 1000 circles of random colors and at random locations each time the user clicks the pane. Make the

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site