By completing this Lab, you will gain further experience using layout containers, GUI controls, formatting/styling, and...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
By completing this Lab, you will gain further experience using layout containers, GUI controls, formatting/styling, and Event-driven programming. Name your Eclipse project Lab4FirstNameLastName. GUI Construction Design and implement a GUI that changes the Label background color to the color chosen by a user. Reference Figure 1 to construct the GUI. • Create the class ColorSelectionGUI. • The GUI consists of Labels, RadioButtons, and CheckBoxes. • The application has four Labels located around the perimeter of the window: o "North", "South", "East", and "West". o The String on the Label should be center-aligned. • • Initially select all four CheckBoxes that indicate the recoloring corresponding Labels. Set the initial background color of the four Labels to "cyan". o Or call the "Cyan" RadioButton's click event manually (see the Hints section) Set the text color of each RadioButton to its associated color (see Hints section). • Initially select the "Cyan" RadioButton to "Cyan" • • RadioButtons should have radio button functionality (only one radio button can be selected at a time). Color Selection West Locations ✓ North South ✔ East West North Background Colors Salmon Spring Green East Orange Cyan South Figure 1. Initial GUI before a user's interaction. CS161 Introduction to Computer Science II Hints ● ● ● If you want to achieve the exact spacing of the provided GUI example, here are some formatting numbers that I used: All sections: O Submit Center section: ■ ■ Vertical gap: 4 North and South Labels: ■ Alignment: Pos.CENTER ■ Preferred size: 220 width, 160 height Horizontal gap: 15 ■ Preferred size: primaryStage.getWidth() width, 40 height You must use this after primaryStage.show() to get the displayed window width. East and West Labels: Alignment: Pos.CENTER Alignment: Pos.CENTER If you don't want to set the background color of every Label individually at the beginning, you can call the "Cyan" RadioButton's Action Event manually using this method (after assigning it the proper event handler): o cyanRdo.fireEvent(new ActionEvent()); Preferred size: 40 width, primaryStage.getHeight() – 80 height - You must use this after primaryStage.show() to get the displayed window height. Since all CheckBoxes are checked initially, this will set all background colors. To set the background color of a control, use the setStyle method: O Ex. northLbl.setStyle("-fx-background-color: springgreen"); To set the text color of a RadioButton or CheckBox, use setStyle(): O Ex. salmonRdo.setStyl("-fx-text-fill: salmon"); Submit the zipped Eclipse project folder to Brightspace. All source code should be properly documented. CS161 Introduction to Computer Science II Event Handling Implement the following event handling class. When the user clicks a RadioButton, change the background color of all Labels according to the selected CheckBoxes. Only one event handler should be written and assigned to all RadioButtons. Reference the examples below: o Figure 2 shows the resulting GUI when the user selects the "Spring Green" RadioButton with all CheckBoxes selected: Color Selection West Locations North South East West Color Selection West North Locations North South East West Figure 2. Select the "Spring Green” background color. Figure 3 shows the resulting GUI when the user deselects "North" and "East" CheckBoxes and clicks the “Salmon” RadioButton. Background Colors Salmon ● Spring Green East Orange Cyan South North Background Colors Salmon X Spring Green Orange Cyan South X East Figure 3. Deselect "North" and "East" CheckBox, click "Salmon" RadioButton. CS161 Introduction to Computer Science II ● Then the user only selects "East" CheckBox and clicks the "Blue" RadioButton. Color Selection West Locations North South East West North Background Colors Salmon Spring Green East O Orange Cyan X South Figure 4. Select only "East" CheckBox, click "Orange" RadioButton. By completing this Lab, you will gain further experience using layout containers, GUI controls, formatting/styling, and Event-driven programming. Name your Eclipse project Lab4FirstNameLastName. GUI Construction Design and implement a GUI that changes the Label background color to the color chosen by a user. Reference Figure 1 to construct the GUI. • Create the class ColorSelectionGUI. • The GUI consists of Labels, RadioButtons, and CheckBoxes. • The application has four Labels located around the perimeter of the window: o "North", "South", "East", and "West". o The String on the Label should be center-aligned. • • Initially select all four CheckBoxes that indicate the recoloring corresponding Labels. Set the initial background color of the four Labels to "cyan". o Or call the "Cyan" RadioButton's click event manually (see the Hints section) Set the text color of each RadioButton to its associated color (see Hints section). • Initially select the "Cyan" RadioButton to "Cyan" • • RadioButtons should have radio button functionality (only one radio button can be selected at a time). Color Selection West Locations ✓ North South ✔ East West North Background Colors Salmon Spring Green East Orange Cyan South Figure 1. Initial GUI before a user's interaction. CS161 Introduction to Computer Science II Hints ● ● ● If you want to achieve the exact spacing of the provided GUI example, here are some formatting numbers that I used: All sections: O Submit Center section: ■ ■ Vertical gap: 4 North and South Labels: ■ Alignment: Pos.CENTER ■ Preferred size: 220 width, 160 height Horizontal gap: 15 ■ Preferred size: primaryStage.getWidth() width, 40 height You must use this after primaryStage.show() to get the displayed window width. East and West Labels: Alignment: Pos.CENTER Alignment: Pos.CENTER If you don't want to set the background color of every Label individually at the beginning, you can call the "Cyan" RadioButton's Action Event manually using this method (after assigning it the proper event handler): o cyanRdo.fireEvent(new ActionEvent()); Preferred size: 40 width, primaryStage.getHeight() – 80 height - You must use this after primaryStage.show() to get the displayed window height. Since all CheckBoxes are checked initially, this will set all background colors. To set the background color of a control, use the setStyle method: O Ex. northLbl.setStyle("-fx-background-color: springgreen"); To set the text color of a RadioButton or CheckBox, use setStyle(): O Ex. salmonRdo.setStyl("-fx-text-fill: salmon"); Submit the zipped Eclipse project folder to Brightspace. All source code should be properly documented. CS161 Introduction to Computer Science II Event Handling Implement the following event handling class. When the user clicks a RadioButton, change the background color of all Labels according to the selected CheckBoxes. Only one event handler should be written and assigned to all RadioButtons. Reference the examples below: o Figure 2 shows the resulting GUI when the user selects the "Spring Green" RadioButton with all CheckBoxes selected: Color Selection West Locations North South East West Color Selection West North Locations North South East West Figure 2. Select the "Spring Green” background color. Figure 3 shows the resulting GUI when the user deselects "North" and "East" CheckBoxes and clicks the “Salmon” RadioButton. Background Colors Salmon ● Spring Green East Orange Cyan South North Background Colors Salmon X Spring Green Orange Cyan South X East Figure 3. Deselect "North" and "East" CheckBox, click "Salmon" RadioButton. CS161 Introduction to Computer Science II ● Then the user only selects "East" CheckBox and clicks the "Blue" RadioButton. Color Selection West Locations North South East West North Background Colors Salmon Spring Green East O Orange Cyan X South Figure 4. Select only "East" CheckBox, click "Orange" RadioButton.
Expert Answer:
Answer rating: 100% (QA)
Below is the code to perform the given task it creates a GUI with labels checkboxes and radio buttons as described It also handles the event when a radio button is clicked to change the background col... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
On March 31, 2019, the balances of the accounts appearing in the ledger of Racine Furnishings Company, a furniture wholesaler, are as follows: a. Prepare a multiple-step income statement for the year...
-
Concept, Inc., has a profit sharing plan with some participants earning $265,000 or more. The company can maximize its participants' annual additions by using what percentage of profit sharing...
-
In 20X0, the Northwest Ballet Association (NBA), a not-for profit performing arts organization, undertook a major capital campaign to fund a new theater, expected to cost $10 million. It was quickly...
-
Use the same facts as problem 20 and prepare entries using the following independent assumptions: a. Lease A is abandoned in 2022. b. Lease A is proved in 2022. c. Insignificant Lease Y, with a cost...
-
As part of the settlement for a class action lawsuit, Hoxworth Corporation must provide sufficient cash to make the following annual payments (in thousands of dollars): The annual payments must be...
-
Suppose you have 135 households in your neighborhood, can you use "=RAND()" function in Excel to randomly select 20 of them to send a survey? a) Write down the codes you would use. b) Show your work...
-
Design the 4-to-1 MUX two ways Write a Verilog module called mux4to1 to implement 4-to-1 multiplexer using functional descriptions and if-else blocks. Write another Verilog module called...
-
You are the Chief Financial Officer and lead Project Development President for a snack. You are presented with a few options about what to do next for value-creation from your teams. However, you...
-
Describe an example you have experience with of the principal-agent problem (for example, you have a desire for your children to listen in school and do well, while for them, goofing off at school...
-
Why do skilled professionals working in the same business often have significantly different forecasts and views of the future? Share an example from your own work experience at CVS Health where your...
-
Taylor Rules and Short-Run Exchange Rate movements for inflation targeting central banks. Consider the following Taylor Rule for the nominal short-term U.S. policy interest rate ($): = ( ) ()( )...
-
what are examples of how purchasing has influenced business within the last 10 years?
-
According to Boxofficemojo.com, the average ticket price in the United States is $8.66. Fifteen years ago in 2001, the average ticket price was $5.66. Prices tend to rise over a 15 year time period...
-
Find the matrix A given that the solution to the weighted least square of matrix A is and that the size of A is a 4x3 matrix.
-
1A. If the researcher is concerned about the number of variables, the nature of the analysis, and completion rates, then, he/she is at which stage of the sampling design process (Figure 11.1 in the...
-
Leslie and Leon Lazo are married and file a joint return for 2012. Leslie's Social Security number is 466-47-3311 and Leon's is 467-74-4451. They live at 143 Snapdragon Drive, Reno, NV 82102. For...
-
Bev and Ken Hair have been married for 3 years. They live at 3567 River Street, Springfield, MO 63126. Ken is a full-time student at Southwest Missouri State University (SMSU) and Bev works as an...
-
David and Darlene Jasper have one child, Sam, who is 6 years old. The Jaspers reside at 4639 Honeysuckle Lane, Los Angeles, CA 90248. David's Social Security number is 577-11-3311, Darlene's is...
-
On January 2, 2018, The Register, a science and technology news site based in Britain, published an article revealing the existence of two major bugs leaving virtually all computers and smartphones...
-
In the 1970s, Special Electric Company brokered the sale of crocidolite asbestos, which is the most toxic form of asbestos, to Johns- Manville Corporation. Special Electric never held possession of...
-
Plaintiffs W. O. and J. C. Lucy had wanted to purchase Ferguson Farm from the Zehmers for at least eight years. One night, Lucy stopped by the establishment the Zehmers operated and said that he bet...
Study smarter with the SolutionInn App