Question
Modify the QuoteOptions Program to change its visual appereance. Present the radio buttons in a vertical column with surrounding border to the left of the
Modify the QuoteOptions Program to change its visual appereance. Present the radio buttons in a vertical column with surrounding border to the left of the quote label.
import javafx.application.Application; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.stage.Stage; public class QuoteOptions extends Application { public void start(Stage primaryStage){ QuoteOptionsPane pane = new QuoteOptionsPane(); pane.setAlignment (Pos.CENTER); pane.setStyle("-fx-background-color: lightgreen"); Scene scene = new Scene (pane, 500, 150);
primaryStage.setTitle("Quote Option"); primaryStage.setScene(scene); primaryStage.show(); } }
import javafx.event.ActionEvent; import javafx.geometry.Pos; import javafx.scene.control.RadioButton; import javafx.scenecontrol.ToggleGroup; import javafx.scene.layout.HBox; import javafx.scene.layout.StackGroup; import javafx.scene.layout.VBox; import javafx.scene.text.Text; import javafx.scene.text.Font; //****************************************************************** //QuoteOptionsPane.Java Author: Melkamu Section: CSIT112_01 // //Demenostrate the use of radio buttons. //****************************************************************** public class QuoteOptionsPane extends HBox{ private Text quote; private string philosophyQuote, carpntryQoute, comedyQuote; private RadioButton philosophyButton, carperntryButton, comedyButton; public class QuoteOptionsPane(){ philosophyQuote = "I think therefore I am."; carpntryQoute = "Measure twice. Cut once"; comedyQuote = "Take my wife. Please."; quote = new Text(PhilosophyQuate); quote.setFont(new Font("Helvetica", 24)); StackPane.setPane = new StackPane(quote); quotePane.setPrefsize(300,100); ToggleGroup group = new ToggleGroup(); philosophyButton = new RadioButton("Philosphy"); philosophyButton.setSelected(true); philosophyButton.setToggleGroup(group); philosophyButtonsetAction(this: : processRadioButtonAction); curpentryButton =new RadioButton(Carpentry); curpentryButton.setTaggleGroup(group); curpentryButton.setOnAction(this ::processRadioButton); comedyButton = new RadioButton("Comedy"); comedyButton.setToggleGroup(group); comedyButton.setOnAction(this:: processRadioButtonAction); VBox option = new VBox(philosophyButton, carpentryButton, comedyButtonButton); options.setAlignment(Pos.CENTER_LEFT); option.setSpacing(10); setSpacing().addAll (options, quotePane); } public void processRadioButtonAction (ActionEvent event){ if (philosophyButton.isSelect()) quote.setText(philosophyQuote); else if (carpentryButton.isSelected()) quote.setText(carpentryQute); else quote.setText(comedyQuote); } }
Quote Options 2 O Comedy Philosophy Take my wife, please Carpentry Quote Options 2 O Comedy Philosophy Take my wife, please CarpentryStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started