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: 70% (10 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...
-
Solve the linear programming problems stated in Problems 1734. Minimize subject to C = 30x+10y 1.8x + 0.9y 270 0.3x + 0.2y = 54 0.01x + 0.03y = 3.9 x, y 0
-
Describe the six categories of early warning signs of potential fraud.
-
Direct and step-down allocation E-books, an online book retailer, has two operating departmentsCorporate Sales and Consumer Salesand two support departmentsHuman Resources and Information Systems....
-
Discuss why people often resist new ideas such as the Relational Model in Business Logic ?
-
Bring forward a real-world company that has expanded to the point that it needs to introduce an accounting information system (AIS). Please include references Construct a PowerPoint presentation that...
-
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.)...
-
a. Describe financial leverage and outline the principal benefit and drawbacks of borrowing funds to finance the acquisition of assets. b. What is the function of debt-rating agencies like DBRS and...
-
Jennifer is required to take a $30,000 minimum distribution from her traditional IRA but decided only to take a distribution of $20,000. For what penalty tax, if any, is she liable?
-
Research a cyber attack that occurred within the past 5 years and develop a presentation to discuss the following: Attack overview What happened? Threat actors Who was involved? Attack Method What...
-
how to a register this entry in the general jounal Jan 22 Accepted a job for the manufacture of 28 units R2 (Racing 2) custom stand-up paddle (SUP) boards for Four Oceanic Designers. The promise date...
-
What is found on the balance sheet of a property and liability insurer?
-
On January 1, 2016, Drugz Inc., a large pharmaceutical company, commenced business operations in Canada. The following information is available: 2018 2019 2020 2021 Reported Income (loss) before tax...
-
Aldor Corporation opened a new store on January 1, 2014. During 2014, the fi rst year of operations, the following purchases and sales of inventory were made: Instructions (a) Calculate the cost of...
-
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...
-
What are the key segments in the premium dog market? What key characteristics do customers in the premium dog segment share? How does this influence their buying process for their dogs? Explain the...
-
I have seen an example of an emerging approach that has been successful in the commercial world. Competition from other businesses operating in the same industry was fierce for the company I worked...
-
give me some Marketing strategies for a Trade School to Engage Students How make those strategies works? Also, ideas to Recruit Students for Trade School with Modern Marketing Tactics
Study smarter with the SolutionInn App