Listing 16.4, ComboBoxDemo.java, gives a program that lets the user view a country?s flag image and description
Question:
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 program. Rewrite the program to read the text description from a file. Suppose that the descriptions are stored in the files description0.txt, . . . , and description8.txt under the text directory for the nine countries Canada, China, Denmark, France, Germany, India, Norway, United Kingdom, and United States, in this order.
Listing
Transcribed Image Text:
1 import javafx.geometry.Insets; 2 import javafx.scene.control.RadioButton; 3 import javafx.scene.control.ToggleGroup; 4 import javafx.scene.layout.BorderPane; 5 import javafx.scene.layout. VBox; 6 import javafx.scene.paint.Color; 8 public class RadioButtonDemo extends CheckBoxDemo { @Override // Override the getPane () method in the super class 10 protected BorderPane getPane () { 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 BorderPane pane = super.getPane (); VBox_paneForRadioButtons = new VBox(20); paneForRadioButtons.setPadding(new Insets(5, 5, 5, 5)); paneForRadioButtons.setStyle("-fx-border-color: green"); paneForRadioButtons.setStyle ("-fx-border-width: 2px; -fx-border-color: green"); RadioButton rbRed = new RadioButton ("Red"); RadioButton rbGreen = new RadioButton("Green"); RadioButton rbBlue = new RadioButton("Blue"); paneForRadioButtons.getChildren().addAll(rbRed, rbGreen, rbBlue); pane.setLeft(paneForRadioButtons); ToggleGroup group = new ToggleGroup(); rbRed.setToggleGroup(group); rbGreen.setToggleGroup(group); rbBlue.setToggleGroup(group); 28 29 30 31 rbRed.setOnAction(e -> { if (rbRed.isSelected()) { text.setFill(Color.RED); 32 33 34 35 36 37 }); rbGreen.set0nAction(e -> { if (rbGreen.isSelected()) { text.setFill(Color.GREEN); 38 39 40 41 42 43 }); rbBlue.setOnAction(e -> { if (rbBlue.isSelected()) { text.setFill(Color.BLUE); 44 45 }); 46 47 return pane; } 48 49 }
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 72% (11 reviews)
Program plan Import the required packages into the program Define a class DispCountryFlag to display flags and their corresponding description by usin...View the full answer
Answered By
Joseph Mwaura
I have been teaching college students in various subjects for 9 years now. Besides, I have been tutoring online with several tutoring companies from 2010 to date. The 9 years of experience as a tutor has enabled me to develop multiple tutoring skills and see thousands of students excel in their education and in life after school which gives me much pleasure. I have assisted students in essay writing and in doing academic research and this has helped me be well versed with the various writing styles such as APA, MLA, Chicago/ Turabian, Harvard. I am always ready to handle work at any hour and in any way as students specify. In my tutoring journey, excellence has always been my guiding standard.
4.00+
1+ 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 lets the user click on a pane to dynamically create and remove points (see Figure 15.28a). When the user left-clicks the mouse (primary button), a point is created and displayed...
-
Write a program that lets the user to enter the order and display the filled Sierpinski triangles as shown in Figure 18.18. Enter an order: Enter an order: Enter an order: Enter an order:
-
Write a program that lets the user create a weighted graph dynamically. The user can create a vertex by entering its name and location, as shown in Figure 29.28. The user can also create an edge to...
-
Roberto finishes a triathlon (750-meter swim, 5-kilometer run, and 20-kilometer bicycle) in 63.2 minutes. Among all men in the race, the mean finishing time was 69.4 minutes with a standard deviation...
-
DeWalden Resources Inc. plans to issue $30,000,000 of 10-year debt in September, and the chief financial officer is concerned that interest rates will rise over the next six months until the debt is...
-
Suppose a number of months before your car battery needs to be replaced follow the exponential distribution with a mean of 50.0 months. a. What is the probability that your car battery will need to...
-
In your organisation how many interviews and interviewers are used? How effective is this approach and why? In what ways could the approach be improved? LO4
-
Berry Company is an architectural firm located in Detroit, Michigan. The company works with small and medium-size construction businesses to prepare building plans according to client contract. Berry...
-
Woodmier Lawn Products introduced a new line of commercial sprinklers in 2020 that carry a one-year warranty against manufacturer's defects. Because this was the first product for which the company...
-
An automatic depth-control system for a robot submarine is shown in Figure P3.7.The depth is measured by a pressure transducer. The gain of the stern plane actuator is K = 1 when the vertical...
-
Programming Exercise 15.30 developed a slide show using images. Rewrite that program to develop a slide show using text files. Suppose ten text files named slide0.txt, slide1.txt, . . . , and...
-
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.)...
-
One year ago, Tyler Stasney founded Swift Classified Ads. Stasney remembers that you took an accounting course while in college and comes to you for advice. He wishes to know how much net income his...
-
Which one of the following is not a part of the Deployment phase of a machine learning development project? Explain what phase(s) address this issue, and why then? Training end users to incorporate...
-
Assist with the following discussion: Topic Discussion #1B: The first half of the term is devoted to leaders preparing themselves for leadership. Peter Senge and his coauthors discuss in The Dawn...
-
You are managing an employee who is not a self-starter, and thus you need to devise a plan to effectively lead this employee. Draft a one page (Times New Roman 12) single space response (plus title...
-
Ontario's minister of training, colleges and universities defended changes to post-secondary education on Monday, saying recently announced decisions are all about the making the system more...
-
"The power of globalization is not about leveraging economies of scale. It's about leveraging economies of knowledge and coordination figuring out how not to reinvent the wheel everywhere you do...
-
Which of the following is the correct margin of error for a 99% confidence interval for the difference in the proportion of male and female college students who worked for pay last summer? a. b. c....
-
Why do CPA firms sometimes use a combination of positive and negative confirmations on the same audit?
-
A slotted Aloha network is working with maximum throughput. a. What is the probability that a slot is empty? b. How many slots, n, on average, should pass before getting an empty slot?
-
Based on Figure 12.3, how do we interpret success in an Aloha network? Figure 12.3 Station has Legend a frame to send K : Number of attempts Tp: Maximum propagation time Tr: Average transmission time...
-
One of the useful parameters in a LAN is the number of bits that can fit in one meter of the medium (n b/m ). Find the value of n b/m if the data rate is 100 Mbps and the medium propagation speed is...
-
You have just been hired as a new management trainee by Earrings Unlimited, a distributor of earrings to various retail outlets located in shopping malls across the country. In the past, the company...
-
You just won a stock picking contest that will pay you $24,000 a year for 26 years, and you get the first payment today. What is the prize worth to you today if your annual opportunity cost rate is...
-
a) Discuss in about 200 words the Hierarchy of the information- based business decision makers. Which level has the best chance of success and why? b) Differentiate between deductive reasoning and...
Study smarter with the SolutionInn App