Modify Listing 28.10, ConnectedCircles.java, to display sets of connected circles in different colors. That is, if two
Question:
Modify Listing 28.10, ConnectedCircles.java, to display sets of connected circles in different colors. That is, if two circles are connected, they are displayed using the same color; otherwise, they are not in same color, as shown in Figure 28.25.
Listing
Transcribed Image Text:
Ч4 (a) (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 20 21 @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 { 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: 69% (13 reviews)
Program Plan Modify ConnectedCircles class that extends Application class start method is used to create a scene setting that scene to stage and show ...View the full answer
Answered By
Somshukla Chakraborty
I have a teaching experience of more than 4 years by now in diverse subjects like History,Geography,Political Science,Sociology,Business Enterprise,Economics,Environmental Management etc.I teach students from classes 9-12 and undergraduate students.I boards I handle are IB,IGCSE, state boards,ICSE, CBSE.I am passionate about teaching.Full satisfaction of the students is my main goal.
I have completed my graduation and master's in history from Jadavpur University Kolkata,India in 2012 and I have completed my B.Ed from the same University in 2013. I have taught in a reputed school of Kolkata (subjects-History,Geography,Civics,Political Science) from 2014-2016.I worked as a guest lecturer of history in a college of Kolkata for 2 years teaching students of 1st ,2nd and 3rd year. I taught Ancient and Modern Indian history there.I have taught in another school in Mohali,Punjab teaching students from classes 9-12.Presently I am working as an online tutor with concept tutors,Bangalore,India(Carve Niche Pvt.Ltd.) for the last 1year and also have been appointed as an online history tutor by Course Hero(California,U.S) and Vidyalai.com(Chennai,India).
4.00+
2+ 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
-
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...
-
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...
-
Modify Listing 28.1, TestGraph.java, to create a file representing graph1. The file format is described in Programming Exercise 28.1. Create the file from the array defined in lines 8?21 in Listing...
-
1) The following information relates to the ABCs depreciable assets. Class 1 - During 2020, a new office building was acquired at a total cost of $623,000. Of this total, it is estimated that the...
-
When a sequence of deoxynucleotides is entered into a translation program (such as the ExPASy Translate tool at www.expasy.org/tools/dna.html), six possible polypeptide sequences are given as...
-
1. Our nation has amassed a huge public debt. Just how huge? Go to http://www.pub- licdebt.treas.gov/sec/sec.htm. In the left-hand column under "The Public Debt." click on Debt Figure. How much is...
-
how should the effectiveness of the product and service development process be judged in terms of fulfilling market requirements?
-
Gross Profit Method Presented below is information related to Jerrold Corporation for the current year. Compute the ending inventory , assuming that (a) Gross profit is 40% of sales; (b) Gross profit...
-
Question 3 Suppose, common stock of a firm pays a constant annual dividend of $ 4 . 8 0 per share. What is one share of this stock worth at a discount rate of 1 3 . 3 percent? $ 6 5 . 2 6 $ 4 0 . 8 9...
-
Change the STORE_REPS table so that NULL values cant be entered in the name columns (First and Last).
-
Modify GraphView in Listing 28.6 to add a new data field tree with a set method. The edges in the tree are displayed in red. Write a program that displays the graph in Figure 28.1 and the DFS/BFS...
-
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...
-
The following information is taken from the financial statements of the Eastern Oil Company for the year ending December 31, 1978 and 1979. On the basis of this information, assess the relative (a)...
-
GATE-2024(Electrical Engineering) question. Q.10 A surveyor has to measure the horizontal distance from her position to a distant reference point C. Using her position as the center, a 200 m...
-
Letf(x) =?x. If the rate of change of f at x= c is twice its rate of change at x=1,then find the value of c?
-
Andrea and Barsha are middle-distance runners for their schools track team. Andreas time A in the 400-meter race on a randomly selected day is approximately Normally distributed with a mean of 62...
-
How has the globalization of firms affected the diversity of their employees? Why has increased diversity put an additional burden on accounting systems?
-
Give an example showing why a network operator might want one class of packets to be given priority over another class of packets.
-
In Section 4.2, we studied FIFO, Priority, Round Robin (RR), and Weighted Fair queueing (WFQ) packet scheduling disciplines? Which of these queueing disciplines ensure that all packets depart in the...
-
Describe how packet loss can occur at output ports. Can this loss he pre vented by increasing the switch fabric speed?
-
If you made a fixed deposit of $10,000 with an annual interest rate of 3% but the rate of inflation for that year is 3% as well, the calculation of Real Interest Rate would be like this
-
Miller Brothers Hardware paid an annual dividend of $1.80 per share last month. Today, the company announced that future dividends will be increasing by 3.20 percent annually. If you require a 9.5...
-
We know that possessing common stocks represents the corresponding ownership of that share of the companys assets. Suppose an investor buys 1% of equity of a levered firm, then her payoff will be A....
Study smarter with the SolutionInn App