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...
-
In Exercises find all values of x for which the series converges. For these values of x, write the sum of the series as a function of x. n=1 (3x)n
-
Sarah Saxon and Jane Rolf are partners in a business called J & S Service. The partnership's work sheet for the year ended December 31 of the current year is provided in the Working Papers....
-
Jan and Deana have been dreaming about owning a boat for some time and have decided that estimating its cash flows will help them in their decision process. They expect to have a disposable annual...
-
what is the basis of property converted from personal use to busoness
-
A ride hailing company has their DB structured in 3 major tables as described in the SCHEMA section below. Write a query to fetch the top 100 users who traveled the most distance using the service....
-
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...
-
Assume the same information as in E9.14 and also assume that the bond is the only investment held by Miron Aggregates Ltd. Instructions a. Prepare a partial comparative statement of financial...
-
Evaluate the significance of stream-of-consciousness techniques in modernist literature. How do these techniques affect the reader's immersion and understanding of a character's psyche ?
-
(a) Do some research to investigate how many supernova explosions have happened in the history of the Milky Way. State the total number and what years each supernova occurred. (b) If the kinetic...
-
7. After how many iterations does the following loop terminate, and what is the actual value of the variable n after the end of the loop? Please explain every loop iteration and keep track on the...
-
Vanda Capital allocates $15m to be managed by a boutique equity sub-fund, for which you are the portfolio manager. Suppose the risk-free rate is 5% and your sub-fund can borrow and lend at the...
-
A disk is to be rotated around an axis perpendicular to its face. we can place the axis through the center or through a point on the rim of the disk. how will the rotational inertia of the first...
-
Allen, an unmarried taxpayer filing single, has no dependents and reports the following items on his 2016 federal income tax return: Adjusted gross...
-
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?
-
Frankie and Pat are a married couple who adopted a child with special needs in a domestic adoption. They paid a total of $7,600 in adoption expenses in 2022, and the adoption was finalized on March...
-
IRM4030: Risk Management Solutions 1. The marginal tax rate of ABC Corp is specified as below: Taxable Income Tax rate $0-$5 10% $5 - $10 20% $10- 30% A firm has its taxable income as the following:...
-
Reliable Gearing currently is all - equity - financed. It has 2 7 , 0 0 0 shares of equity outstanding, selling at $ 1 0 0 a share. The firm is considering a capital restructuring. The low - debt...
Study smarter with the SolutionInn App