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: 71% (14 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...
-
1. The electric field strength at a distance of 3.00 x10 m from a charged object is 4.60 x 10' N/c. What is the electric field strength at a distance of 4.45 x 10' m from the same object?
-
In order to study the seriousness of drinking and driving, a researcher obtains records from past car crashes. Drivers are partitioned into a group that had no alcohol consumption and another group...
-
The Bigco pension plan has invested in dozens of VC funds. The director of the pension plan is preparing his annual report to the Bigco board of directors. Summary information for Bigcos VC portfolio...
-
Get the minimal cost expression from the given Minterms using a 3 variable K-Map. X1 7) Fm(0, 2, 4) 1 X2X3 00 mo 01 m1 11 m3 10 10 m2 HU m4 m5 m7 m6
-
The finance director for the City of Green Falls printed the General Fund Revenues and Appropriations Ledgers shown below for the year just ended. The beginning-of-the-year fund balance was $160,160....
-
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,...
-
At the end of the 2014 annual reporting period, Barnard Corporations baiance sheet showed the following: During 2015, the following selected transactions (summarized) were completed: a. Sold and...
-
John wants to train his daughter to excuse herself before she leaves the table. Although he does not know how often he will reward her for excusing herself, he does know that he will not reward her...
-
Jason is the owner-manager of Perfecto Cleaning ("PC"), a CCPC in the business of offering commercial cleaning services to hotels, office buildings and banquet halls. Jason has been in business for...
-
a) List and define three ways to describe the cost of a service. b) Name three approaches to capital budgeting. c) What is the difference between gross and net revenue? d) What is the difference...
-
After selling its assets and paying all of its liabilities, a corporation has cash of $1,237,000 available for distribution to its only shareholder. The corporation was established 10 years ago with...
-
A company with a calendar year-end purchased a machine on 1/1/X1. The following information is available for 20X1: Description Amount Cost $ 80,000 Estimated residual value $ 5,000 Total estimated...
-
Let d represent the distance between the point (5, - 3) and any point, (x, y), on the parabola y = 0.5x2 + 1. a. Write an equation for d in terms of x. b. What is the minimum distance? What are the...
-
Ex. (17): the vector field F = x i-zj + yz k is defined over the volume of the cuboid given by 0x a,0 y b, 0zc, enclosing the surface S. Evaluate the surface integral ff, F. ds?
-
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...
-
2. i (6 points) Given the financial statements of the Lehman Brothers Inc in 2007, calculate the Assets Turns, Current Ratio, Leverage Ratio, Return on Equity, and determine its bankruptcy risk using...
-
KBS International Plc has decided to purchase a new machine that costs 4.2 million. The machine will be depreciated on a 20 percent reducing balance basis and will be worth nothing at the end of 4...
-
What statutory deductions are typically applicable to commission payments?
Study smarter with the SolutionInn App