Question: Edit this code so it isn't one big start method and has multiple methods, will thumbs up . import javafx.application.Application; import javafx.stage.Stage; import javafx.scene.Scene; import

Edit this code so it isn't one big start method and has multiple methods, will thumbs up.
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.control.RadioButton;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.layout.HBox;
import javafx.scene.layout.BorderPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Rectangle;
import javafx.geometry.Pos;
public class TF extends Application {
@Override
public void start(Stage primaryStage){
VBox CPane = new VBox(5);
CPane.setAlignment(Pos.CENTER);
Circle c1= getCircle();
Circle c2= getCircle();
Circle c3= getCircle();
CPane.getChildren().addAll(c1, c2, c3);
Rectangle tb = new Rectangle();
tb.setFill(Color.WHITE);
tb.setWidth(35);
tb.setHeight(100);
tb.setStroke(Color.BLACK);
tb.setStrokeWidth(2);
StackPane stopSign = new StackPane(tb, CPane);
HBox RadioButtonsPane = new HBox(10);
RadioButtonsPane.setAlignment(Pos.CENTER);
RadioButton butRed = new RadioButton("Red");
RadioButton butYellow = new RadioButton("Yellow");
RadioButton butGreen = new RadioButton("Green");
ToggleGroup group = new ToggleGroup();
butRed.setToggleGroup(group);
butYellow.setToggleGroup(group);
butGreen.setToggleGroup(group);
RadioButtonsPane.getChildren().addAll(butRed, butYellow, butGreen);
BorderPane TL = new BorderPane();
TL.setCenter(stopSign);
TL.setBottom(RadioButtonsPane);
butRed.setOnAction(e ->{
if (butRed.isSelected()){
c1.setFill(Color.RED);
c2.setFill(Color.WHITE);
c3.setFill(Color.WHITE);
}
});
butYellow.setOnAction(e ->{
if (butYellow.isSelected()){
c1.setFill(Color.WHITE);
c2.setFill(Color.YELLOW);
c3.setFill(Color.WHITE);
}
});
butGreen.setOnAction(e ->{
if (butGreen.isSelected()){
c1.setFill(Color.WHITE);
c2.setFill(Color.WHITE);
c3.setFill(Color.GREEN);
}
});
Scene scene = new Scene(TL,200,150);
primaryStage.setTitle("Traffic Light");
primaryStage.setScene(scene);
primaryStage.show();
}
private Circle getCircle(){
Circle c = new Circle(10);
c.setFill(Color.WHITE);
c.setStroke(Color.BLACK);
return c;
}
public static void main(String[] args){
Application.launch(args);
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!