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...
-
Why are Asian Americans an attractive market segment? Why can they be difficult for marketers to reach?
-
Petitioner Curtis Flowers has been tried six separate times for the murder of four employees of a Mississippi furniture store. Flowers is black; three of the four victims were white. At the first two...
-
Sandi Scott obtained a patent on a small electronic device and organized Scott Products, Inc., to produce and sell the device. During the first month of operations, the device was very well received...
-
Your web application's database is MySQL.How you can establish the database connection and if database connection is failed, you able to detect the errors that cause the database connection failed....
-
Zia Co. makes flowerpots from recycled plastic in two departments, Molding and Packaging. Zia uses the weighted average method, and units completed in the Molding department are transferred to the...
-
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,...
-
Write the formula of iron(III) sulfate.
-
Houda Motors has just announced results that show that the FCF for the past year is $35 million. An experienced analyst believes that the growth rate of the FCF for the next year 10 years will be 25%...
-
A bar assembly is loaded with force P at one end and constrained at the other end, as shown in the figure below. Use finite element method to determine: a. The displacement at each node of 2, 3, and...
-
Abbas and Sabrina, aged 32 and 33 respectively, are living in a house that they bought last year. They have only one child, Vincent, aged 2. They plan to have another child in two or three years....
-
Question 4 of 19 The present value of an investment with the following year-end cash flows (CF) and a 12% required annual rate of return is closet to: Year Cash Flow (THB) 1 100,000 2 150,000 5...
-
An autoregressive stationary time series W, is defined by the relationship: W, = 0.5W-1+0.4W-2-0.1W-3 + Z for integer times 1, where {Z} represents a set of uncorrelated random variables with mean 0...
-
At a point due north of the transmitter, how should a magnetic dipole antenna be oriented to serve as a receiver? An electric dipole antenna used to transmit radio waves is oriented vertically.
-
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...
-
Reducing your costs by implementing a cost reduction process that is also being implemented by your competitors is likely to lead to sustained competitive advantage. Discuss
-
An owner can lease his building for $150,000 per year for three years.The explicit cost of maintaining the building is $50,000 and the implicit cost is $65,000. All revenues are received and costs...
-
2. See Figure 1. If the economy is operating with aggregate spending AE1;Calculate the marginal propensity to save (MPS) * 3. See Figure 1. If the economy is operating with aggregate spending...
Study smarter with the SolutionInn App