Question: FIX The Code. Hi, I need help to fix this code. import javafx.application.Application; import javafx.geometry.Insets; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox;

FIX The Code.

Hi, I need help to fix this code.

import javafx.application.Application;

import javafx.geometry.Insets;

import javafx.scene.Scene;

import javafx.scene.control.Button;

import javafx.scene.control.Label;

import javafx.scene.layout.BorderPane;

import javafx.scene.layout.HBox;

import javafx.scene.layout.VBox;

import javafx.stage.Stage;

import javafx.scene.image.Image;

import javafx.scene.image.ImageView;

public class ShowHBoxVBox extends Application {

@Override // Override the start method in the Application class

public void start(Stage primaryStage) {

// Create a border pane

BorderPane pane = new BorderPane();

// Place nodes in the pane

pane.setTop(getHBox());

pane.setLeft(getVBox());

// Create a scene and place it in the stage

Scene scene = new Scene(pane);

primaryStage.setTitle("ShowHBoxVBox"); // Set the stage title

primaryStage.setScene(scene); // Place the scene in the stage

primaryStage.show(); // Display the stage

}

private HBox getHBox() {

HBox hBox = new HBox(15);

hBox.setPadding(new Insets(15, 15, 15, 15));

hBox.setStyle("-fx-background-color: gold");

hBox.getChildren().add(new Button("Computer Science"));

hBox.getChildren().add(new Button("Chemistry"));

ImageView imageView = new ImageView(new Image("image/us.gif"));

hBox.getChildren().add(imageView);

return hBox;

}

private VBox getVBox() {

VBox vBox = new VBox(15);

vBox.setPadding(new Insets(15, 5, 5, 5));

vBox.getChildren().add(new Label("Courses"));

Label[] courses = {new Label("CSCI 1301"), new Label("CSCI 1302"),

new Label("CSCI 2410"), new Label("CSCI 3720")};

for (Label course: courses) {

VBox.setMargin(course, new Insets(0, 0, 0, 15));

vBox.getChildren().add(course);

}

return vBox;

}

/**

* The main method is only needed for the IDE with limited

* JavaFX support. Not needed for running from the command line.

*/

public static void main(String[] args) {

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 Databases Questions!