Listing 28.10, ConnectedCircles.java, allows the user to create circles and determine whether they are connected. Rewrite the
Question:
Listing 28.10, ConnectedCircles.java, allows the user to create circles and determine whether they are connected. Rewrite the program for rectangles. The program lets the user create a rectangle by clicking a mouse in a blank area that is not currently covered by a rectangle. As the rectangles are added, the rectangles are repainted as filled if they are connected or are unfilled otherwise, as shown in Figure 28.25b?c.
Listing
Transcribed Image Text:
(b) (c) 1 import javafx.application. Application; 2 import javafx.geometry.Point2D; 3 import javafx.scene.Node; 4 import javafx.scene.Scene; 5 import javafx.scene.layout.Pane; 6 import javafx.scene.paint.Color; 7 import javafx.scene.shape.Circle; 8 import javafx.stage.Stage; 10 public class ConnectedCircles extends Application { 11 12 13 14 15 16 17 18 19 @Override // Override the start method in the Application class public void start(Stage primaryStage) { // Create a scene and place it in the stage Scene scene = new Scene(new CirclePane(), 450, 350); primaryStage.setTitle("ConnectedCircles"); // Set the stage title primaryStage.setScene(scene); // Place the scene in the stage primaryStage.show(); // Display the stage /** Pane for displaying circles */ class CirclePane extends Pane { 20 21 public CirclePane () { this.setOnMouseClicked(e -> { if (!isInsideACircle(new Point2D(e.getX(), e.getY()))) { // Add a new circle getChildren ().add(new Circle(e.getX(), e.getY(), 20)); colorIfConnected(); 22 23 24 25 26 27 28 29 }); 30
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 50% (10 reviews)
Program Plan Create a class DrawRectangles that extends Application class start method is used to create a scene setting that scene to stage and showing the stage MyRectanglePane class extends Pane cl...View the full answer
Answered By
Ruchi Mahajan
I am Dr. Ruchi Mahajan, PhD in the field of experimental nuclear Physics. Currently, I am working as Guest Faculty at Department of Physics, Panjab University Chandigarh from January 2019 on wards. I have taught Physics to Graduate and Post Graduate classes. I have also worked at a coaching institute where I have taught CSIR-NET, IIT-JAM, GATE, TIFR, JEST aspirants from last 7 years. I am passionate about teaching Science to students from all background. I have continuously developed my teaching skills time to time by serving as a faculty at such a prestigious institute. I love to share and gain knowledge. I have qualified various national level examinations (CSIR NET, IIT JEE, PHD Entrance test, NGPE etc.) and was a gold medalist. I am very confident and hardworking person. I hope students will definitely enjoy interacting with me.
0.00
0 Reviews
10+ Question Solved
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Question Posted:
Students also viewed these Computer science questions
-
a. Search the Java website for information about how to use a JTextArea, its constructors, and its setText() and append() methods. Write an application that allows the user to select options for a...
-
Rewrite Programming Exercise using a thread to control the clock animation. Modify Listing, ClockPane.java, to add the animation into this class and add two methods?start()?and?stop()?to start and...
-
Write an application that allows the user to choose insurance options in JCheckBoxes. Use a ButtonGroup to allow the user to select only one of two insurance typesHMO (health maintenance...
-
The Sales Discounts account is a contra account to which of the following accounts? Cost of Goods Sold Sales Returns and Allowances Purchases Discounts Sales Revenue
-
Eukaryotic initiation factor eIF2B is a guanine nucleotide exchange factor. Explain why eIF2B would enhance the activity of eIF2.
-
A patient on a brown rice and skim milk diet is required to have at least 800 calories and at least 32 grams of protein per day. Each serving of brown rice contains 200 calories and 5 grams of...
-
Fantastic Sams and Defendants PSTEVO, LLC and Jeremy Baker entered into a franchise agreement pursuant to which Fantastic Sams granted PSTEVO a franchise to operate a Fantastic Sams Salon. According...
-
Given the following network with activity times in months, determine the earliest start and finish times, latest start and finish times, and slack for each activity. Indicate the critical path and...
-
Translate the following business rules into an object relational diagram (ORD) using UMLet (See the above Object Relational Diagram examples). a USER has many ROLES. a USER has one BIRTHDATE. a USER...
-
The following information is for Brad's Burger Company: 1. Cash balance per bank, July 31, $7,363. 2. July bank service charge not recorded by the depositor, $22. 3. The bank erroneously charged...
-
Modify Listing 28.10, ConnectedCircles.java, to enable the user to drag and move a circle. Listing 1 import javafx.application. Application; 2 import javafx.geometry.Point2D; 3 import...
-
Modify Listing 28.10, ConnectedCircles.java, to enable the user to remove a circle when the mouse is clicked inside the circle. Listing 1 import javafx.application. Application; 2 import...
-
Suppose that you are given the choice between two life preservers that are identical in size, the first a light one filled with Styrofoam and the second a very heavy one filled with gravel. If you...
-
Talk about the skills needed to be a pilot beyond the physical element of driving the aircraft. Becoming a pilot is more than just attending flight training, flight classes, and passing the flight...
-
A security makes monthly payment forever. The payment is growing at a constant rate of 0.5%. What should be the first monthly payment if it is sold at $2,000 and required rate of return is 4%?
-
Suppose the real rate is 1.88 percent and the inflation rate is 0.89 percent. What rate would you expect to earn on a Treasury bill? Use exact formula and answer in percent to two decimals.
-
Wonder Woman and Superman fly to an altitude of 1530 km, carrying betwen them a chest full of jewels that they intend to put into orbit around Earth. They want to make this tempting treasure...
-
Compute the present value of a $5,100 deposit in year 3, and another $4,600 deposit at the end of year 6 using an 9 percent interest rate. (Do not round intermediate calculations and round your final...
-
Core Enterprises makes peripheral equipment for computers. The company's new controller only has the following partial information for the past two months: The current year's predetermined overhead...
-
Kenneth Hubbard has prepared the following list of statements about managerial accounting and financial accounting. 1. Financial accounting focuses on providing information to internal users. 2....
-
What is meant by destination-based forwarding? How does this differ from generalized forwarding (assuming youve read Section 4.4, which of the two approaches are adopted by Software-Defined...
-
Consider a router that interconnects three subnets: Subnet 1, Subnet 2, and Subnet 3. Suppose all of the interfaces in each of these three subnets are required to have the prefix 223.1.17/24. Also...
-
In Section 4.2, we saw that a router typically consists of input ports. Output ports, a switching fabric and a routing processor Which of these are implemented in hardware and which are implemented...
-
Write a program in Ruby to find all prime numbers within a given range using the Sieve of Eratosthenes algorithm.
-
Question 1 [CLO 2] For the following transactions pass journal entries, prepare ledger accounts and also prepare the trial balance. 2018 April 1. Saeed started business with cash $200,000, stock...
-
i have written an informational interview e-mail to female television host and meet her to get to learn out of her. After a meeting i wants to thank her for sharing her time and knowledge to me. how...
Study smarter with the SolutionInn App