Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please code this in Java with comments USING JavaFX and NOT JPanels. (20 pts) Design and implement a GUI that changes the Label background color

Please code this in Java with comments USING JavaFX and NOT JPanels.
image text in transcribed
image text in transcribed
image text in transcribed
(20 pts) 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 North West Locations Background Colors North Salmon South Spring Green East Orange West 1 Cyan East South Figure 1. Initial GUI before a user's interaction. (10 pts) 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 North West Locations Background Colors North Salmon South Spring Green East Orange West Cyan East South Figure 2. Select the "Spring Green background color. Figure 3 shows the resulting GUI when the user deselects "North and East" CheckBoxes and click the "Salmon RadioButton. Color Selection X North West Locations Background Colors North Salmon South Spring Green East Grange West Cyan East South Figure 3. Deselect "North" and "East" CheckBox, click "Salmon" RadioButton. Then the user only selects "East" CheckBox and click the "Blue" RadioButton. Color Selection North West Locations Background Colors North Salmon South Spring Green East Orange West South Figure 4. Select only "East" CheckBox, click "Orange RadioButton. Hints If you want to achieve the exact spacing of the provided GUI example, here are some formatting numbers that I used: All sections: Alignment: Pos.CENTER o Center section: Preferred size: 220 width, 160 height Horizontal gap: 15 Vertical gap: 4 North and South Labels: . Preferred size: primaryStage.getWidth() width, 40 height You must use this after primaryStage.show() to get the displayed window width. Alignment: Pos.CENTER o East and West Labels: Preferred size: 40 width, primaryStage getHeight() - 80 height You must use this after primary Stage show to get the displayed window height 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): ocyando.fireEvent(new ActionEvent()); 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(): Ex. salmonRdo.setStyl(-fx-text-fill: salmon")

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions

Question

b. Does senior management trust the team?

Answered: 1 week ago

Question

3. Write a policy statement to address these issues.

Answered: 1 week ago

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago