Rewrite Listing 15.13 using a thread to animate a flag being raised. Compare the program with Listing
Question:
Rewrite Listing 15.13 using a thread to animate a flag being raised. Compare the program with Listing 15.13 by setting the delay time to 10 in both programs. Which one runs the animation faster?
Listing
Transcribed Image Text:
1 import javafx.animation.PathTransition; 2 import javafx.application. Application; 3 import javafx.scene.Scene; 4 import javafx.scene.image. ImageView; 5 import javafx.scene.layout.Pane; 6 import javafx.scene.shape.Line; 7 import javafx.stage.Stage; 8 import javafx.util.Duration; 10 public class FlagRisingAnimation extends Application { 11 @Override // Override the start method in the Application class 12 public void start(Stage primaryStage) { 13 14 15 16 17 18 19 20 21 // Create a pane Pane pane - new Pane (); // Add an image view and add it to pane ImageView imageView = new ImageView("image/us.gif"); pane.getChildren().add(imageView); // Create a path transition PathTransition pt = new PathTransition(Duration.millis(10000), 22 new Line(100, 200, 100, 0), imageView); 24 pt.play(); // Start animation pt.setCycleCount(5); 26 // Create a scene and place it in the stage Scene scene - new Scene (pane, 250, 200); primarystage.setTitle("FlagRisingAnimation"); // Set the stage title primaryStage.setScene (scene); // Place the scene in the stage primaryStage.show(); // Display the stage 28 29 31 32 }
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 66% (9 reviews)
Program Plan Refer to class FlagRisingAnimation from Listing 1513 and add delay in it using delayProperty function and run it Create a new class FlagR...View the full answer
Answered By
Kainat Shabbir
i am an experienced qualified expert with a long record of success helping clients overcome specific difficulties in information technology, business and arts greatly increasing their confidence in these topics. i am providing professional services in following concerns research papers, term papers, dissertation writing, book reports, biography writing, proofreading, editing, article critique, book review, coursework, c++, java, bootstarp, database.
5.00+
184+ Reviews
255+ 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
-
Listing 15.17 BallPane.java using a thread to animate bouncing ball movements. Listing 1 import javafx.animation.KeyFrame; 2 import javafx.animation.Timeline; 3 import...
-
Rewrite Programming Exercise 20.5 using a thread to animate bouncing ball movements. The example in Section displays multiple bouncing balls. Extend the example to detect collisions. Once two balls...
-
Rewrite Exercise using a thread to control car racing. Compare the program with Exercise by setting the delay time to 10 in both programs. Which one runs the animation faster? Write a program that...
-
Partners have fiduciary obligations to each other. Explain what this means and give examples.
-
A possible mechanism for the pathology of trinucleotide repeat diseases is aberrant translation in which all three reading frames are used. Which repeating amino acid residues will result from the...
-
What impact is it likely to have on the ratings for the 5:30 P.M. newscast? Why?
-
Make a list of five jobs that you consider would be best rewarded by a merit-based system and five more that are best rewarded via the goal-based approach. LO9
-
Bedard Corporation reported net income of $300,000 in 2010 and had 200,000 shares of common stock outstanding throughout the year. Also outstanding all year were 45,000 options to purchase common...
-
In an efficient market, which of these could explain why some stock prices are more volatile. 1. There is more uncertainty about the new information that could come up in the market. 2. There is a...
-
The beam supports the distributed load shown. Determine the resultant internal loadings acting on the cross section at point C. Assume the reactions at the supports A and B are vertical. 4 kN/m A...
-
Rewrite Listing 30.1 to display the output in a text area, as shown in Figure 30.30. Listing a 1b2b3b 4b 5 b6bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb 7 8bbbbbbbbbbbbbbbbbbbb 9bb10 16 11 12 13 14...
-
Write a program that launches 1,000 threads. Each thread adds 1 to a variable sum that initially is 0. Define an Integer wrapper object to hold sum. Run the program with and without synchronization...
-
Let Y 1 < Y 2 < < Y 10 be the order statistics of a random sample from a continuous-type distribution with distribution function F(x). What is the joint distribution of V 1 = F(Y 4 ) F(Y 2 ) and...
-
Discuss charitable purpose trusts under Section 3(1), Charities Act 2011.
-
Amadeus Corporation is considering the issue of a new product to be added to its product mix. They hired you, a recent business graduate from MacEwan, for conducting the analysis. The production line...
-
I have attached a case study, primarily based on your textbook chapter reading assignments. The background material for the case also references chapters 3 and 15, not assigned for this course....
-
On December 1 , 2 0 2 5 , Sandhill Distributing Company had the following account balances.DebitCash$ 7 , 1 0 0 Accounts Receivable 4 , 5 0 0 Inventory 1 1 , 9 0 0 Supplies 1 , 2 0 0 Equipment 2 2 ,...
-
Cindy Greene works at Georgia Mountain Hospital. The hospital experiences a lot of business closer to summer when the temperature is warmer. Cindy is meeting with her supervisor to go over the budget...
-
To collect information such as passwords, online criminals use spoofing to direct Internet users to fraudulent websites. In one study of Internet fraud, students were warned about spoofing and then...
-
On July 1, 2011, Flashlight Corporation sold equipment it had recently purchased to an unaffiliated company for $480,000. The equipment had a book value on Flashlights books of $390,000 and a...
-
Install and compile the Python programs TCPClient and UDPClient on one host and TCPServer and UDPServer on another host. a. Suppose you run TCPClient before you run TCPServer. What happens? Why? b....
-
Suppose that in UDPClient.py, after we create the socket, we add the line: clientSocket.bind((, 5432)). Will it become necessary to change UDPServer.py? What are the port numbers for the sockets in...
-
Can you configure your browser to open multiple simultaneous connections to a Web site? What are the advantages and disadvantages of having a large number of simultaneous TCP connections?
-
whether the following statements is TRUE or FALSE by providing a brief explanation . b) The Value at Risk of a first project is 8 and the Value at Risk of a second project is 5. The Value at Risk of...
-
Fill out a spreadsheet using the following information to perform a NPV analysis. Revenues in each of years 1-3 = $20,000 Year 0 initial investment = $40,000 Inventory level = $10,000 in year 1,...
-
A firm has $9.5 Billion debt outstanding, with a yield to maturity of 5.3% and a coupon rate of 4.6%. They have 148 million preferred shares outstanding, currently trading at $92.29. They also have...
Study smarter with the SolutionInn App