How to create an image in a flowpane using a button, but the button and the flowpane are on different scenes

I am creating a game that includes a weapon shop(In a different scene), in the weapon shop are buttons which execute methods that create and place the images in the respective flowpane. but when running an error occurs which says “this.lane1Wall” which is the flowpane is null. I have no idea how to fix this error. Any Ideas?

PS: I tried putting a button in the same scene as the battle(The same scene as the flowpane) and it works??? but not when the button is in the weapon shop.

Code:

package game.gui;

import game.engine.Battle;
import game.engine.BattlePhase;
import game.engine.base.Wall;
import game.engine.lanes.Lane;
import game.gui.*;

import game.engine.titans.Titan;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.FlowPane;
import javafx.stage.Stage;

import javax.swing.*;
import java.io.File;
import java.io.IOException;
import java.util.PriorityQueue;

public class EasyBattleController {

    private Stage stage= new Stage();
    private Scene scene ;
    private Parent root;

private Battle easygamebattle;

    {
        try {
            easygamebattle = new Battle(1, 0, 100, 3 , 250);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
    private Lane lane1 =  easygamebattle.getOriginalLanes().get(0);
    private Lane lane2 = easygamebattle.getOriginalLanes().get(1);
    private Lane lane3 = easygamebattle.getOriginalLanes().get(2);
    private Wall wall1 = lane1.getLaneWall();
    private Wall wall2 = lane2.getLaneWall();
    private Wall wall3 = lane3.getLaneWall();

    @FXML
    private Button PassTurnButton;
    @FXML
    private Label ScoreLabel = new Label();
    @FXML
    private Label TurnLabel= new Label();
    @FXML
    private Label PhaseLabel= new Label();
    @FXML
    private Label Lane1Health= new Label();
    @FXML
    private Label Lane2Health= new Label();
    @FXML
    private Label Lane3Health= new Label();
    @FXML
    private Button WeaponShopButton;
    @FXML
    private Label ResLabel= new Label();
    @FXML
    private Label Lane1Danger= new Label();
    @FXML
    private Label Lane2Danger= new Label();
    @FXML
    private Label Lane3Danger= new Label();
    @FXML
    private  Button BackToGameButton = new Button();
    @FXML
    private FlowPane lane1Wall;
    @FXML
    private FlowPane lane2Wall;
    @FXML
    private FlowPane lane3Wall;
    @FXML
    private Button dddd;
    @FXML
    private Label ResLabelShop =new Label();
    @FXML
private Button PiercingButLane1= new Button();

    public void passTurnPress (){
        easygamebattle.passTurn();
        ScoreLabel.setText("Score:" + easygamebattle.getScore());
        TurnLabel.setText("Turn:" + easygamebattle.getNumberOfTurns());
       PhaseLabel.setText(String.valueOf(easygamebattle.getBattlePhase()));
        ResLabel.setText((String.valueOf(easygamebattle.getResourcesGathered())));
        Lane1Health.setText(String.valueOf(wall1.getCurrentHealth()));
        Lane2Health.setText(String.valueOf(wall2.getCurrentHealth()));
        Lane3Health.setText(String.valueOf(wall3.getCurrentHealth()));
        Lane1Danger.setText(String.valueOf(lane1.getDangerLevel()));
        Lane2Danger.setText(String.valueOf(lane2.getDangerLevel()));
        Lane3Danger.setText(String.valueOf(lane3.getDangerLevel()));

    }
    public void switchToWeaponShop (ActionEvent event) throws IOException {
        Parent root = FXMLLoader.load(getClass().getResource("weaponshop.fxml"));
        Stage  stageweaponshop = new Stage();
        Scene sceneweaponshop = new Scene(root);
        stageweaponshop.setScene(sceneweaponshop);
        stageweaponshop.setResizable(true);
        stageweaponshop.setHeight(780);
        stageweaponshop.setWidth(1280);
        stageweaponshop.show();
        ResLabelShop.setText((String.valueOf(easygamebattle.getResourcesGathered())));
    }
        public void piercingDeployLane1() {
            Image piercing = new Image( getClass().getResourceAsStream("Piercingcannon.png"));
            ImageView imageView = new ImageView(piercing);
            imageView.setFitHeight(50);
            imageView.setFitWidth(50);
           lane1Wall.getChildren().add(imageView);
        }

I tried putting a button in the same scene as the battle(The same scene as the flowpane) and it works??? but not when the button is in the weapon shop.

New contributor

Ibrahim Darwish is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật