Java Class

Hello everyone, I just finished with one assignment that I had as a homework for my Java class, this was not that hard but it was tedious to figure out what were the exactly coordinates to centralize that divides the circles. Here you have it!

//        Author: Kevin Uriel Azuara Fonseca
//  Write a JavaFX application that displays 10,000 very small circles (radius of 1 pixel) in random locations within the visible area.
//  Fill the dots on the left half of the scene red and the dots on the right half of the scene green.
//  Use the getWidth method of the scene to help determine the halfway point.

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.shape.Circle;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import java.util.Random;
import javafx.scene.Group;

public class Class615 extends Application {
    private final int FINAL_CIRCLES = 10000;
    private final int radius = 1;
    Group root = new Group();
    Random randomGenerator = new Random();
    public void start(Stage primaryStage) {

        for (int count = 1; count <= FINAL_CIRCLES; count++) {

            Circle circle = new Circle(randomGenerator.nextInt(500) , randomGenerator.nextInt(250), radius);
            if (circle.getCenterX() < 250) {
            } else {
        Scene scene = new Scene(root, 500, 250, Color.BLACK);
        primaryStage.setTitle("Drawing 10000 circles");
    public static void main(String[] args) {

That’s pretty much it. I hope for myself that you find this article helpful. Do me a favor and please share it with your friends!.

Leave a Reply

Back to Top