Question: Could you please help me to fix this Java program. I want too type in the enter field (stack order) then I want to use

Could you please help me to fix this Java program. I want too type in the enter field (stack order) then I want to use Toggle, Push, Pop, Clear. These buttons should work. Right now these buttons are not working and when enter text it doesn't appear in the screen. Please help me to make these buttons work

//Main imports

import javafx.application.Application; // Adding application

import javafx.scene.Scene; // Making the scene

import javafx.stage.Stage; // For stage

//All Scenes

import javafx.scene.layout.BorderPane; // Making bordorpane

import javafx.scene.layout.HBox; // Making HBox

import javafx.scene.layout.VBox; // Making VBox

//All Scene.Controls

import javafx.scene.control.Label; // For labels

import javafx.scene.control.TextField; // For textfeild

import javafx.scene.control.Button; // For Buttons

import javafx.scene.control.TextArea; // Making Text area

import javafx.geometry.Insets; // For Padding

public class Assignment extends Application {

Stage Main_Stage; //Making my stage

@Override

public void start(Stage primaryStage) {

Main_Stage = primaryStage; // Setting window to = the primaryStage

//TopPane will hold the HBox and VBox

BorderPane Pane = new BorderPane();

Pane.setPadding(new Insets(20));

//HBox will hold Label, buttons and

HBox Hbox = new HBox();

Label label = new Label("Stacking Order");

label.setPadding(new Insets(5, 10, 10, 10));

Button Toggle = new Button("Toggle ");

Button Push = new Button("Push ");

Button Pop = new Button("Pop ");

Button Clear = new Button("Clear ");

Hbox.getChildren().addAll(label, Toggle,Push,Pop,Clear);

//Vbox will hold the TextField(aka textbox)

VBox Vbox = new VBox();

TextField TxtBox = new TextField();

TxtBox.setText(" ");

Vbox.getChildren().addAll(TxtBox);

//Making a textArea that will read the Textbox

TextArea txtArea = new TextArea();

txtArea.setText(" Rear --> { " + " } <-- Front");

HBox Output = new HBox(txtArea);

//Setting the height and width of them

txtArea.setPrefHeight(200);

txtArea.setPrefWidth(400);

//Adding the Hbox,Vbox,Output to Pane

Pane.setTop(Hbox);

Pane.setLeft(Vbox);

Pane.setBottom(Output);

primaryStage.setTitle("Javafx Project: My Name");

Scene scene = new Scene(Pane, 400, 300);

primaryStage.setScene(scene);

primaryStage.show();

}

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