Question

In: Computer Science

Write a JavaFX application that draws 10 circles of random radius in random locations. Leave all...

Write a JavaFX application that draws 10 circles of random radius in random locations. Leave all circles unfilled except for the largest circle which should be filled with a translucent red (30% opaque) . If multiple circles have the same largest size, fill any one of them. Hint: keep track of the largest circle as you generate them, then change fill to red. Thankuou

Solutions

Expert Solution

Please find the code below:

RandomCirclesWithLargestDiff.java

package gui;

import java.util.Random;

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


public class RandomCirclesWithLargestDiff extends Application {
   public static void main(String[] args) {
       launch(args);
   }
   @Override
   public void start(Stage primaryStage) {
       Scene scene = new Scene(new Group(), 1000, 1000);
       Group rowCircle = (Group) scene.getRoot();
       Random rand = new Random();
       Circle largest=null;
       for(int i=0;i<10;i++){
           Circle circle = new Circle(rand.nextInt(1000),rand.nextInt(1000),rand.nextInt(100));
           if(largest==null){
               largest =circle;
           }else if(largest.getRadius()<circle.getRadius()){
               largest = circle;
           }
           circle.setStroke(Color.BLACK);
           circle.setFill(Color.TRANSPARENT);
           rowCircle.getChildren().add(circle);
       }
      
       largest.setOpacity(0.3);
       largest.setFill(Color.RED);
      
       primaryStage.setScene(scene);
       primaryStage.show();
   }
}

output:


Related Solutions

Write a JavaFX application that draws a circle using a rubberbanding technique. The circle size is...
Write a JavaFX application that draws a circle using a rubberbanding technique. The circle size is determined by a mouse drag. Use the initial mouse press location as the fixed center point of the circle. Compute the distance between the current location of the mouse pointer and the center point to determine the current radius of the circle.
In a JavaFX application there is a TextField control(tfRadius) for taking input of a circle's radius....
In a JavaFX application there is a TextField control(tfRadius) for taking input of a circle's radius. A respective square whose diagonal is the circle's diameter can then be created. There are three other controls in this application: a button(btCalculate), two textareas(trCircleArea, trSquareArea). When the button is clicked, the circle's area is calculated and displayed on trCircleArea, furthermore, the square's area is also calculated and displayed on trSquareArea. Please write portions of codes which calculates the circle's area and the square's...
In a JavaFX application there is a TextField control(tfRadius) for taking input of a circle’s radius....
In a JavaFX application there is a TextField control(tfRadius) for taking input of a circle’s radius. A respective square whose diagonal is the circle's diameter can then be created. There are three other controls in this application: a button(btCalculate), two textareas(trCircleArea, trSquareArea). When the button is clicked, the circle's area is calculated and displayed on trCircleArea, furthermore, the square's area is also calculated and displayed on trSquareArea. Please write the portions of codes which calculates the circle’s area and the...
Write a JavaFX application that presents two buttons and a number (initially 50) to the user....
Write a JavaFX application that presents two buttons and a number (initially 50) to the user. Label the buttons Increment and Decrement. When the increment button is pushed, increment the displayed value. Likewise, decrement the value when the decrement button is pushed. This has to use Java.Fx and not Java.Awt
In Java and using JavaFX, write a client/server application with two parts, a server and a...
In Java and using JavaFX, write a client/server application with two parts, a server and a client. Have the client send the server a request to compute whether a number that the user provided is prime. The server responds with yes or no, then the client displays the answer.
Java Write a JavaFX application that displays a button and a number. Every time the button...
Java Write a JavaFX application that displays a button and a number. Every time the button is pushed, change the number to a random value between 1 and 100. Thank you and can you show a picture of the result as well
Write a JavaFX application that displays a Label containing the opening sentence or two from your...
Write a JavaFX application that displays a Label containing the opening sentence or two from your favorite book. Save the project as FXBookQuote1a. Add a button to the frame in the FXBookQuote program. When the user clicks the button, display the title of the book that contains the quote in a second label. Save the project as FXBookQuote1b // FXBookQuote1a.java import javafx.application.Application; import static javafx.application.Application.launch; import javafx.geometry.Insets; import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.scene.layout.Pane; import javafx.scene.text.Font; import javafx.stage.Stage; public class FXBookQuote1a...
Write a program that draws a fixed circle centered at (100, 60) with radius 50. Whenever...
Write a program that draws a fixed circle centered at (100, 60) with radius 50. Whenever the mouse is moved, display a message indicating whether the mouse point is inside the circle at the mouse point or outside of it. Write in Java please.
Using NetBeans IDE, write a JavaFX application that allows theuser to choose insurance options. Use...
Using NetBeans IDE, write a JavaFX application that allows the user to choose insurance options. Use a ToggleGroup to allow the user to select only one of two insurance types—HMO (health maintenance organization) or PPO (preferred provider organization). Use CheckBoxes for dental insurance and vision insurance options; the user can select one option, both options, or neither option. As the user selects each option, display its name and price in a text field; the HMO costs $200 per month, the...
(Not in Swing) Write a JavaFX application that creates polyline shapes dynamically using mouse clicks. Each...
(Not in Swing) Write a JavaFX application that creates polyline shapes dynamically using mouse clicks. Each mouse click adds a new line segment to the current polyline from the previous point to the current mouse position. Allow the user to end the current polyline with the double click. Also, provide a button that clears the window and allows the user to begin again.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT