I'm developing a rather simple javafx application which has a few different scenes, my first scene is to add a Show object to a generic linked list and then in the second scene to add a performance of one of those shows to that object (e.g add matinee or evening performance to the show Annie)
I've created the first scene and can add Show objects to the linked list but I can't populate the tableview in the second scene with the created shows for the user to select and add a performance
This is what my add show controller looks like:
public class AddShowController {
@FXML private TextField titleField;
@FXML private TextField cirField,stlField, balField;
@FXML private Slider runTimeSlider;
@FXML private DatePicker startDatePicker, endDatePicker;
TheLinkedList<Show> showList = new TheLinkedList<>();
private static AddShowController instance;
public AddShowController() {
instance = this;
}
public static AddShowController getInstance(){
return instance;
}
public void addShowButtonPushed (ActionEvent e){
showList.addElement(new Show (titleField.getText(),
(int) runTimeSlider.getValue(),
startDatePicker.getValue().toString(),
endDatePicker.getValue().toString(),
cirField.getText(),
stlField.getText(),
balField.getText()));
}
As you can see I've tried creating an instance of the controller so i could access the linked list from the add performance controller but no joy.
This is the add performance controller:
public class AddPerfController {
@FXML private ChoiceBox perfTimeChoiceBox;
@FXML private TableView<Show> showTable;
@FXML private TableColumn<Show, String> titleColumn;
@FXML private TableColumn<Show, String> runTimeColumn;
@FXML private TableColumn<Show, String> startDateColumn;
@FXML private TableColumn<Show, String> endDateColumn;
@FXML private TableColumn<Show, String> cirTicketPriceColumn;
@FXML private TableColumn<Show, String> stlTicketPriceColumn;
@FXML private TableColumn<Show, String> balTicketPriceColumn;
private ObservableList<Show> showData = FXCollections.observableList(AddShowController.getInstance().showList);
public void initialize() {
perfTimeChoiceBox.getItems().addAll("Matinee","Evening");
perfTimeChoiceBox.setValue("Matinee");
titleColumn.setCellValueFactory(new PropertyValueFactory<>("title"));
runTimeColumn.setCellValueFactory(new PropertyValueFactory<>("runningTime"));
startDateColumn.setCellValueFactory(new PropertyValueFactory<>("startDate"));
endDateColumn.setCellValueFactory(new PropertyValueFactory<>("endDate"));
cirTicketPriceColumn.setCellValueFactory(new PropertyValueFactory<>("cirTicketPrice"));
stlTicketPriceColumn.setCellValueFactory(new PropertyValueFactory<>("stlTicketPrice"));
balTicketPriceColumn.setCellValueFactory(new PropertyValueFactory<>("balTicketPrice"));
showData.add(new Show("Annie", 100,"12/12/2019", "14/12/2019","10","15", "20"));
showTable.setItems(showData);
}