Help with making a scene in JavaFX!

Hello.I am new to Java and I am trying to develop a project in which I have some classes and i have to build scenes for them in JavaFX.I have been trying for days now to finish a Scene but unfortunately i can’t.Here is a sample of my code along with an image showing how the Scene should appear to users when finished.Thanks in advance.

package lab.unipi.gui;


import javafx.event.EventHandler;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.GridPane;
import lab.unipi.core.Store;

import java.util.ArrayList;
import java.util.List;

public class StoreSceneCreator extends SceneCreator implements EventHandler<MouseEvent> {

	//List of cities
	ArrayList<Store> storeList;
	//Flow Pane
	FlowPane buttonFlowPane;
	//Grid Panes
	GridPane rootGridPane, inputFieldsPane;
	//2nd Scene Buttons
	Button addBtn, showBtn, changeBtn, deleteBtn;
	//2nd Scene Labels
	Label cityLbl, storeLbl;
	//2nd Scene Text Fields
	TextField storeField, cityField;
	//Table View
	TableView<Store> storeTableView;
	
	// Arxikopoihsh Scene Creator //
	public StoreSceneCreator(double width, double height) {
		super(width, height);
		
		// Arxikopoihsh Pediwn-Fields //
		storeList = new ArrayList<>();
		rootGridPane = new GridPane();
		buttonFlowPane = new FlowPane();
		cityLbl = new Label("City");
		storeLbl = new Label("Store Name");
		storeField = new TextField();
		cityField = new TextField();
		addBtn = new Button("New Store");
		showBtn = new Button("View all");
		changeBtn = new Button("Update");
		deleteBtn = new Button("Delete");
		inputFieldsPane = new GridPane();
		storeTableView = new TableView<>();
		
		// Customize buttonFlowPane //
		buttonFlowPane.setHgap(10);
		buttonFlowPane.getChildren().add(addBtn);
		buttonFlowPane.getChildren().add(showBtn);
		buttonFlowPane.getChildren().add(changeBtn);
		buttonFlowPane.getChildren().add(deleteBtn);
		buttonFlowPane.setAlignment(Pos.BOTTOM_CENTER);
		
		// Customize inputFieldsPane //
		inputFieldsPane.setAlignment(Pos.TOP_RIGHT);
		inputFieldsPane.setVgap(10);
		inputFieldsPane.setHgap(10);
		inputFieldsPane.add(cityLbl, 0, 0);
		inputFieldsPane.add(cityField, 1, 0);
		inputFieldsPane.add(storeLbl, 0, 1);
		inputFieldsPane.add(storeField, 1, 1);
		
        // Customize rootGridPane //
		rootGridPane.setVgap(10);
		rootGridPane.setHgap(10);
		rootGridPane.add(inputFieldsPane, 1, 0);
		rootGridPane.add(storeTableView, 0, 0);
		rootGridPane.add(buttonFlowPane, 0, 2);
		
		// Customize TableView//
		TableColumn<Store, String> storecodeColumn = new TableColumn<>("Store Code");
		storecodeColumn.setCellValueFactory(new PropertyValueFactory<>("store code"));
		storeTableView.getColumns().add(storecodeColumn);
		
		TableColumn<Store, String> storenameColumn = new TableColumn<>("Store Name");
		storenameColumn.setCellValueFactory(new PropertyValueFactory<>("store name"));
		storeTableView.getColumns().add(storenameColumn);
		
		TableColumn<Store, String> cityColumn = new TableColumn<>("City");
		cityColumn.setCellValueFactory(new PropertyValueFactory<>("city"));
		storeTableView.getColumns().add(cityColumn);
		
		// Desimo Buttons //
		addBtn.setOnMouseClicked(this);
		showBtn.setOnMouseClicked(this);
		changeBtn.setOnMouseClicked(this);
		deleteBtn.setOnMouseClicked(this);
		storeTableView.setOnMouseClicked(this);
		


		
		
	}

	@Override
	public void handle(MouseEvent event) {
		if (event.getSource() == addBtn) {
			String CityName = cityField.getText();
			String NameOfStore = storeField.getText();
			double StoreCode = Math.random();
			createStore(CityName, NameOfStore);
		}
		if (event.getSource() == showBtn) {
			String CityName = cityField.getText();
			String NameOfStore= storeField.getText();
			showStore(CityName, NameOfStore);
			
			tableSync();
			clearTextFields();
		}
		if (event.getSource() == deleteBtn) {
			deleteStore(storeField.getText());
			
			tableSync();
			clearTextFields();
		}
		if (event.getSource() == changeBtn) {
			String NameOfStore = storeField.getText();

		}
		if (event.getSource() == storeTableView) {
			Store selectedStore = storeTableView.getSelectionModel().getSelectedItem();
			if (selectedStore != null) {
				cityField.setText(selectedStore.getCityName());
				storeField.setText(selectedStore.getNameOfStore());
			}
		}
		
	}

	
	public void deleteStore(String CityName) {
		for (int i = 0; i<storeList.size(); i++) {
			if(storeList.get(i).getCityName().equals(CityName)) { 
				storeList.remove(i);
				break;
			}
		}
	}
	
	public void createStore(String CityName, String NameOfStore) {
		Store s = new Store(CityName, NameOfStore);
		storeList.add(s);
		
	}
	
	
	
	public void showStore(String CityName, String NameOfStore) {
		for(Store s : storeList) {
			if ((s.getCityName()).equals(CityName)) {
				((Store) s).setNameOfStore(NameOfStore);
			}
		}
	}

	
	public void clearTextFields() {
		cityField.setText("");
		storeField.setText("");
	}
	
	
	
	
	@Override
	Scene createScene() {
		return new Scene(rootGridPane, width, height);
	}
	
	
	// Sygxronismos stoixeiwn tableView me storeList //
	public void tableSync() {
		List<Store> items = storeTableView.getItems();
		items.clear();
		for (Store s : storeList) {                   
			if (s instanceof Store) {
				items.add((Store) s);
			}
		}
	}
	
	
}

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.