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: 66% (15 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. Arrows up or down: If we move from the cartel outcome to the duopoly outcome, the price ___________, the quantity per firm __________, and the profit per firm __________. 2. A dominant strategy is...
-
Describe as many situations as you can in which there is a principal and an agent in the context of microlenders? How do the examples relate to one another? Do the proposed solutions to any one of...
-
You are managing a company that stocks and distributes hardware. The company employs two purchasing agents who receive combined salaries of $90,000. They process six thousand purchase requests per...
-
6.18 Is college worth it? Part II: Exercise 6.16 presents the results of a poll where 48% of 331 Americans who decide to not go to college do so because they cannot afford it. (a) Calculate a 90%...
-
Shankman Limited is a private company reporting under ASPE. Its comparative balance sheet at December 31 is as follows: Additional information: 1. Profit for 2014 was $200,000 2. Equipment was...
-
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,...
-
Adidas AG reports the following balance sheet accounts for the year ended December 31, 2008 (euros in thousands.) Prepare the balance sheet for this company as of December 31, 2008, following usual...
-
Sherrod, Inc., reported pretax accounting income of $88 million for 2021. The following information relates to differences between pretax accounting income and taxable income: a. Income from...
-
2. Taking on the role of the management group that has been charged by Max Radford to assess what is really going on in the development/growth of the business of Muskoka Lakehouse Restaurants: (a)...
-
PharmaOne Inc. is a private company that operates a chain of 3 0 drug stores in Western Canada. PharmaOne is considering upgrading the software in its pharmacies to allow doctors offices to transmit...
-
Simon Company's year-end balance sheets follow. At December 31 Assets Cash Accounts receivable, net Merchandise inventory Prepaid expenses Plant assets, net Total assets Liabilities and Equity...
-
Apply topological sorting algorithm 7 5 6 4 2 3 1 0
-
1- You are the project manager for a new web-based online shopping system. Due to market competition, your management has directed you to go live with your systems one week earlier than originally...
-
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...
-
Problem 3 PCA Using the Fish Market Data Consider again the data in the previous problem, focusing just on the Perch case. Remember that you only use the test data for the final evaluation. The model...
-
A $24 credit to Revenue was posted as a $240 credit. By what amount is the Revenue account in error?
-
-/14 View Policies Current Attempt in Progress Blossom Enterprises relies heavily on a copier machine to process its paperwork. Recently the copy clerk has not been able to process all the necessary...
Study smarter with the SolutionInn App