Write a program that displays a flag rising up, as shown in Figure 15.14. As the national
Question:
Write a program that displays a flag rising up, as shown in Figure 15.14. As the national flag rises, play the national anthem. (You may use a flag image and anthem audio file from Listing 16.15.)
The animation simulates a flag rising.
Listing
Transcribed Image Text:
FagRising Animation O| FlagRisingAnimation FagRisingAnimation х 1 import javafx.application.Application; 2 import javafx.collections.FXCollections; 3 import javafx.collections.Observablelist; 4 import javafx.stage.Stage; 5 import javafx.geometry.Pos; 6 import javafx.scene. Scene; 7 import javafx.scene.control.Button; 8 import javafx.scene.contro1.ComboBox; 9 import javafx.scene.control.Label; 10 import javafx.scene.image.Image; 11 import javafx.scene.image.ImageView; 12 import javafx.scene.layout.BorderPane; 13 import javafx.scene.layout. HBox; 14 import javafx.scene.media.Media; 15 import javafx.scene.media.MediaPlayer; 16 17 public class FlagAnthem extends Application { 18 19 20 21 22 private final static int NUMBER_OF_NATIONS private final static String URLBase = "http://cs.armstrong.edu/liang/common"; private int currentIndex = 0; 7; @0verride // Override the start method in the Application class public void start(Stage primaryStage) { Image [] images = new Image [NUMBER_OF_NATIONS]; MediaPlayer[] mp = new MediaPlayer[NUMBER_OF_NATIONS]; 23 24 25 26 27 28 29 30 31 32 33 // Load images and audio for (int i = 0; i < NUMBER_OF_NATIONS; i++) { images [i] mp[i] = new MediaPlayer(new Media( URLBase + "/audio/anthem/anthem" + i + ".mp3")); = new Image (URLBase + "/image/flag" + i + ".gif"); 34 Button btPlayPause - new Button (">"); btPlayPause.setOnAction (e -> { if (btPlayPause.getText().equals(">")) { btPlayPause.setText ("||"); mp[currentIndex]. pause(); } else { btPlayPause.setText(">"); mp[currentIndex].play(); 35 36 37 38 39 40 41 42 43 44 }); 45 46 ImageView imageView = new ImageView(images[currentIndex]); ComboBox
FagRising Animation O| FlagRisingAnimation FagRisingAnimation х 1 import javafx.application.Application; 2 import javafx.collections.FXCollections; 3 import javafx.collections.Observablelist; 4 import javafx.stage.Stage; 5 import javafx.geometry.Pos; 6 import javafx.scene. Scene; 7 import javafx.scene.control.Button; 8 import javafx.scene.contro1.ComboBox; 9 import javafx.scene.control.Label; 10 import javafx.scene.image.Image; 11 import javafx.scene.image.ImageView; 12 import javafx.scene.layout.BorderPane; 13 import javafx.scene.layout. HBox; 14 import javafx.scene.media.Media; 15 import javafx.scene.media.MediaPlayer; 16 17 public class FlagAnthem extends Application { 18 19 20 21 22 private final static int NUMBER_OF_NATIONS private final static String URLBase = "http://cs.armstrong.edu/liang/common"; private int currentIndex = 0; 7; @0verride // Override the start method in the Application class public void start(Stage primaryStage) { Image [] images = new Image [NUMBER_OF_NATIONS]; MediaPlayer[] mp = new MediaPlayer[NUMBER_OF_NATIONS]; 23 24 25 26 27 28 29 30 31 32 33 // Load images and audio for (int i = 0; i < NUMBER_OF_NATIONS; i++) { images [i] mp[i] = new MediaPlayer(new Media( URLBase + "/audio/anthem/anthem" + i + ".mp3")); = new Image (URLBase + "/image/flag" + i + ".gif"); 34 Button btPlayPause - new Button (">"); btPlayPause.setOnAction (e -> { if (btPlayPause.getText().equals(">")) { btPlayPause.setText ("||"); mp[currentIndex]. pause(); } else { btPlayPause.setText(">"); mp[currentIndex].play(); 35 36 37 38 39 40 41 42 43 44 }); 45 46 ImageView imageView = new ImageView(images[currentIndex]); ComboBox cboNation = new ComboBox<> (); Observablelist items = ("Denmark", "Germany", "China", "India", "Norway", "UK", "US"); cboNation.getItems ().addA11(items); cboNation.setValue(items.get(0)); cboNation.setOnAction(e -> { mp[currentIndex].stop(); currentIndex = items.indexOf(cboNation.getValue()); imageView.setImage(images [currentIndex]); mp [currentIndex].play(); }); 47 FXCo1lections.observableArrayList 48 49 50 51 52 53 54 55 56 57
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 75% (8 reviews)
Program Plan The program creates an interface that displays a flag rising up that is with reference ...View the full answer
Answered By
Lynn Wathigo
I am passionate about teaching,especially subjects in the humanities field. I enjoy reading and creative writing, one of my favorite areas to tutor.
I look forward to tutoring a student with similar interests, and helping the improve their grades.
Thank you.
0.00
0 Reviews
10+ 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
-
Write a program that displays a bean machine introduced in Exercise, as shown in Figure. The bean machine, also known as a quincunx or the Galton box, is a device for statistics experiments named...
-
Write a program that displays a running fan, as shown in Figure 15.33c. Use the Pause, Resume, Reverse buttons to pause, resume, and reverse fan running. Pause Reverse Resume (c)
-
Write a program that displays a circle of radius 10 pixels filled with a random color at a random location on a pane, as shown in Figure 15.29b. When you click the circle, it disappears and a new...
-
Craps is a dice game in which two fair dice are cast. If the roller shoots a 7 or 11 on the rst roll, he or she wins. If the roller shoots a 2, 3, or 12 on the rst roll, he or she loses. (a) Compute...
-
Branger Ltd. has the choice of issuing floating-rate debt at LIBOR + 1% or fixed-rate debt at Swaps 6%. Likewise, Creeson Plastics can issue floating-rate debt at LIBOR + 2.5% or fixed-rate debt at...
-
Solve the linear programming problems stated in Problems 1734. Minimize and maximize P = 3x + 5y subject to x + 2y = 6 x + y 4 2x + 3y = 12 x, y 0
-
Describe the role of an organizations personnel in compliance and antifraud efforts.
-
(EPS with Stock Dividend and Extraordinary Items) Agassi Corporation is preparing the comparative financial statements to be included in the annual report to stockholders. Agassi employs a fiscal...
-
Why is the relational model more important above the other models?
-
Comparative SFP accounts of Jensen Limited, which follows IFRS, appear below: Additional information: 1. Equipment that cost $10,000 and was 40% depreciated was sold in 2020. 2. Cash dividends were...
-
Listing 16.4, ComboBoxDemo.java, gives a program that lets the user view a country?s flag image and description by selecting the country from a combo box. The description is a string coded in the...
-
Write a program that simulates four cars racing, as shown in Figure 16.47b. You can set the speed for each car, with maximum 100. 2 Car 3: 10 Car 4: Car 1: Car 2: 5 (b)
-
Chek Corporation had outstanding 200,000 shares of $5 par-value common stock on August 13, 2016. On that date, it declared a 15 percent common stock dividend distributable on September 15 to...
-
Which term represents the sum of money allocated or set aside for a specific purpose within a budget?
-
Which bond should UM purchase? Q: Mike is a high net worth individual (HNWI). His marginal tax rate is the top rate of 37%. He has a 401k and a traditional IRA account. Which bonds should he buy in...
-
What is the term used to describe a temporary funding mechanism that allows the government to continue operating when a budget has not yet been approved?
-
CASE in the United States- Respondent (Albert) is making a "special appearance" to contest jurisdiction. Discuss Subject Matter Jurisdiction, In-rem Jurisdiction, and Personal Jurisdiction. Address...
-
Trend Analysis and Benchmarking If a project is expected to cost $180,000 and produce cash flows over the next 3 years of $80,000, $90,000, and $15,000 respectively, what is the payback period,...
-
You are given the following information about Meesha Novelty's inventory for the month of July. Instructions (a) Calculate the cost of goods available for sale and the number of units of ending...
-
Southwestern Punch was made by Frutayuda, Inc. and sold in 12-ounce cans to benefit victims of Hurricane Zero. The mean number of ounces placed in a can by an automatic fill pump is 11.7 with a...
-
Another useful parameter in a LAN is the bit length of the medium (L b ), which defines the number of bits that the medium can hold at any time. Find the bit length of a LAN if the data rate is 100...
-
Based on Figure 12.15, how do we interpret success in an Aloha network? Figure 12.15 Station has a frame to send K= 0 Legend K: Number of attempts Tg: Backoff time IFS: Interframe Space RTS: Request...
-
We have defined the parameter a as the number of frames that can fit the medium between two stations, or a = (T p )/(T fr ). Another way to define this parameter is a = L b /F b , in which L b is the...
-
Combine the following and reduce to lowest terms where appropriate. a+4 2a+3 1. 5y 5y 2. 4a x - a y 47 -IX 3. + 27 - 3 MIN y z II 3X 5Y 4. 16A2B 24AB 7x 4 5. 10ab 10ab
-
Any global marketing strategy, that is in the words of Peter Drucker (2003)" any commitment of present resources to future expectations", has to start with taking stock of the changes in the global...
-
8. The graph below is a model graph for one-way bus fare for different locations A, B,C, and D. Find the four possible Hamilton circuit. the sum of the weight of the edge, and the total fare of each...
Study smarter with the SolutionInn App