Write a program that displays two circles with radius 10 at location (40, 40) and (120, 150)
Question:
Write a program that displays two circles with radius 10 at location (40, 40) and (120, 150) with a line connecting the two circles, as shown in Figure 15.30b. The distance between the circles is displayed along the line. The user can drag a circle. When that happens, the circle and its line are moved, and the distance between the circles is updated.
Transcribed Image Text:
Exercise15 16 36
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 62% (16 reviews)
import javafxapplicationApplication import javafxgeometryPoint2D import javafxsceneScene import javafxscenelayoutPane import javafxscenepaintColor import javafxsceneshapeCircle import javafxsceneshapeLine import javafxscenetextText import javafxstageStage public class Exercise1516 extends Application Override Override the start method in the Application class public void startStage primaryStage Pane pane new Pane Circle circle1 new Circle40 40 10 circle1setFillColorWHITE circle1setStrokeColorBLACK Circle circle2 new Circle120 150 10 circle2setFillColorWHITE circle2setStrokeColorBLACK Line line new Linecircle1getCenterX circle1getCenterY circle2getCenterX circle2getCenterY double distance new Point2Dcircle1getCenterX circle1getCenterYdistancecircle2getCenterX circle2getCenterY Text text new Textcircle1getCenterX circle2getCenterX 2 circle1getCenterY circle2getCenterY 2 intdistance panegetChildrenaddAllline circle1 circle2 text circle1setOnMouseDraggede circle1setCenterXegetX circle1setCenterYegetY linesetStartXegetX linesetStartYegetY double d new Point2Dcircle1getCenterX circle1getCenterYdistancecircle2getCenterX circle2getCenterY textsetXcircle1getCenterX circle2getCenterX 2 textsetYcircle1getCenterY circle2getCenterY 2 textsetTextd circle2setOnMouseDraggede circle2setCenterXegetX circle2setCenterYegetY linesetEndXegetX linesetEndYegetY double d new Point2Dcircle1getCenterX circle1getCenterYdistancecircle2getCenterX circle2getCenterY textsetXcircle1getCenterX circle2getCenterX 2 textsetYcircle1getCenterY circle2getCenterY 2 textsetTextintd Create a scene and place it in the stage Scene scene new Scenepane 400 250 primaryStagesetTitleExercise1516 Set the stage title primaryStagesetScenescene Place the scene in the stage primaryStageshow Display the stage The main method is only needed for the IDE with limited JavaFX support Not needed for running from the command line public static void mainString args launchargs import javafxapplicationApplication import javafxsceneScene import javafxsceneinputMouseButton import javafxscenelayout import javafxsceneshapeCircle import javafxsceneshape ...View the full answer
Answered By
JAPHETH KOGEI
Hi there. I'm here to assist you to score the highest marks on your assignments and homework. My areas of specialisation are:
Auditing, Financial Accounting, Macroeconomics, Monetary-economics, Business-administration, Advanced-accounting, Corporate Finance, Professional-accounting-ethics, Corporate governance, Financial-risk-analysis, Financial-budgeting, Corporate-social-responsibility, Statistics, Business management, logic, Critical thinking,
So, I look forward to helping you solve your academic problem.
I enjoy teaching and tutoring university and high school students. During my free time, I also read books on motivation, leadership, comedy, emotional intelligence, critical thinking, nature, human nature, innovation, persuasion, performance, negotiations, goals, power, time management, wealth, debates, sales, and finance. Additionally, I am a panellist on an FM radio program on Sunday mornings where we discuss current affairs.
I travel three times a year either to the USA, Europe and around Africa.
As a university student in the USA, I enjoyed interacting with people from different cultures and ethnic groups. Together with friends, we travelled widely in the USA and in Europe (UK, France, Denmark, Germany, Turkey, etc).
So, I look forward to tutoring you. I believe that it will be exciting to meet them.
3.00+
2+ Reviews
10+ Question Solved
Related Book For
Introduction To Java Programming And Data Structures Comprehensive Version
ISBN: 9780136520238
12th Edition
Authors: Y. Daniel Liang
Question Posted:
Students also viewed these Computer science questions
-
Write a program that displays the recommended weight (kg), given the users age and height (cm). The formula for calculating the recommended weight is recommendedWeight = (height - 100 + age / 10) *...
-
Two circles of radius b intersect as shown in Figure 6 with their centers 2a apart (0 ¤ a ¤ b). Find the area of the region of their overlap. -a
-
Write a program that draws two circles with radius 15 pixels, centered at random locations, with a line connecting the two circles. The distance between the two centers is displayed on the line, as...
-
Why is it so easy to develop and then retain racial prejudices? How can we break this mold?
-
The static deflection of a cantilever beam is described by xy = P/(6EIA) y2 (3L - y) Where P is the load applied at the end of the beam, and xy is the vertical deflection at a point a distance y from...
-
Gauging the Favorableness of Variances When variances occur, they are described as being either favorable or unfavorable. When actual activity consumes more time or money than initially planned, an...
-
Formal employee performance appraisals are normally conducted once or twice per year. A. True B. False
-
Warren Buffett, arguably the most famous investor in the United States, is the CEO of Berkshire Hathaway (BRK), a company that has enjoyed great success in terms of its stock price. Below are the...
-
A bond ladder O A. is a strategy that helps you achieve your financial goals by "climbing the ladder." O B. guarantees that you will always get the best interest rates on the bonds you invest in. O...
-
What is each shareholder's realized gain or loss? b. What is each shareholder's recognized gain or loss? c. What is each shareholder's basis in their stock? When does their holding period begin? d....
-
Write a program that displays a rectangle. You can point the mouse inside the rectangle and drag (i.e., move with mouse pressed) the rectangle wherever the mouse goes. The mouse point becomes the...
-
Write a program that draws line segments using the arrow keys. The line starts from (100, 100) in the pane and draws toward east, north, west, or south when the right-arrow key, up-arrow key,...
-
Use the Thomas algorithm to solve the following tridiagonal matrix equation for the x vector. -6 3 0 1.5 0 0 3 0 -4.5 3 0 0 0 0 3 4.5 -7.5 0 4.5 -7.5 0 0 0 3 -4.5 X1 X2 X3 X4 X5 0 100 0 0
-
Use the Comparison Theorem to determine whether the integral is convergent or divergent. L da
-
Problem 3 (2 scenarios) Scenario 1: Rocky Inc hired a new intern from CSU to help with year-end inventory. The intern computed the inventory counts at the end of 2020 and 2021. However, the intern's...
-
A CM reactor receives influent containing 10.0 mg/L of tracer for 2 h. Then tracer addition is terminated but the flow remains steady. The volume of the reactor is 10 L and the flow rate is 2 L / h....
-
Solve the given system of equations graphically by using a graphing calculator. y=5x x+y2=81 Find the solution with the smaller x-value. x= y= (Type an integer or a decimal rounded to one decimal...
-
I-The market for Sony's Playstation5 game console has changed from 2021 to 2023. With restrictions from the Covid-19 pandemic ending people are finding other entertainment options available such as...
-
PepsiCo's financial statements are presented in Appendix B. Financial statements of The CocaCola Company are presented in Appendix C. The complete annual reports of PepsiCo and Coca-Cola, including...
-
Compare and contrast debt financing and equity financing as ways of starting a new business. Does one have an overall advantage over the other? What situation is more favorable to the use of debt...
-
Listing 12.16, ReplaceText.java, gives a program that replaces text in a source file and saves the change into a new file. Revise the program to save the change into the original file. For example,...
-
Write a program to create a file named Exercise12_15.txt if it does not exist. Write 100 integers created randomly into the file using text I/O. Integers are separated by spaces in the file. Read the...
-
Suppose that a text file contains an unspecified number of scores separated by blanks. Write a program that prompts the user to enter the file, reads the scores from the file, and displays their...
-
Be prepared to explain the texts comprehensive To illustrate the issues related to interest capitalization, assume that on November 1, 2016, Shalla Company contracted Pfeifer Construction Co. to...
-
On April 1, 2020. Indigo Company received a condemnation award of $473,000 cash as compensation for the forced sale of the company's land and building, which stood in the path of a new state highway....
-
The market price of a stock is $24.55 and it is expected to pay a dividend of $1.44 next year. The required rate of return is 11.23%. What is the expected growth rate of the dividend? Submit Answer...
Study smarter with the SolutionInn App