Question: JAVAFX * * * * Why won't my stack list show up in my list view? I've made it observable but it won't work: import

JAVAFX**** Why won't my stack list show up in my list view? I've made it observable but it won't work:
import java.io.*;
import java.util.*;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.ListView;
import javafx.scene.control.TextField;
import javafx.scene.layout.Background;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
import static javafx.scene.paint.Color.GREEN;
import static javafx.scene.paint.Color.WHITE;
import javafx.stage.Stage;
public class VisualStack extends Application{
Button push = new Button("PUSH");
Button pop = new Button("POP");
Button peek = new Button("PEEK");
TextField textInput = new TextField();
Label title = new Label("My Visual Stack. Stack Size: 23");
Label popLabel = new Label();
Label peekLabel = new Label();
Label error = new Label("Error:");
Label stack = new Label("Stack");
Stack list = new Stack<>();
ObservableList list1= FXCollections.observableList(list);
ListView stackArea = new ListView<>(list1);
GridPane layoutPane = new GridPane();
Pane backgroundPane = new Pane();
public void start(Stage primaryStage){
list.ensureCapacity(23);
title.setTextFill(WHITE);
error.setTextFill(WHITE);
stack.setTextFill(WHITE);
push.setMinSize(100,10);
push.setOnAction(e ->{
list.push(textInput.getText());
textInput.setText("");
});
pop.setMinSize(100,10);
pop.setOnAction(e ->{
popLabel.setText((String)list.pop());
list.pop();
});
peek.setMinSize(100,10);
peek.setOnAction(e ->{
peekLabel.setText((String)list.peek());
list.peek();
});
layoutPane.setHgap(10);
layoutPane.setVgap(10);
layoutPane.setAlignment(Pos.CENTER);
layoutPane.add(title,0,0);
layoutPane.add(push,0,1);
layoutPane.add(textInput,1,1);
layoutPane.add(pop,0,2);
layoutPane.add(peek,0,3);
layoutPane.add(error,0,4);
layoutPane.add(stack,3,1);
layoutPane.add(stackArea,3,2);
layoutPane.add(popLabel,3,3);
layoutPane.add(peekLabel,4,3);
backgroundPane.setBackground(Background.fill(GREEN));
backgroundPane.getChildren().add(layoutPane);
Scene scene = new Scene(backgroundPane,800,600);
primaryStage.setTitle("Visual Stack");
primaryStage.setScene(scene);
primaryStage.show();
}
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 Programming Questions!