How to change a borderPane of a controller in another controller in javaFX

0

I'm having trouble trying to change the BorderPanel Center of my project in javaFX. In the code I call a function that is in the Side-Menu controller to change the Main, but whenever I do this the following error occurs: "Exception in thread" JavaFX Application Thread "java.lang.RuntimeException: java.lang.reflect.InvocationTargetException "

MenuController Button Controller

package app.controllers;

import java.io.IOException;

import com.jfoenix.controls.JFXButton;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
public class btnRecursosHumanosController {

	@FXML
	private JFXButton btnRecursosHumanosController;
	
	@FXML 
	public void btn_click(ActionEvent event) throws IOException {
		FXMLLoader loader = new FXMLLoader(getClass().getResource("/app/views/Main.fxml"));
		MainController setController = (MainController) loader.getController();	
		setController.getCenter();
	}
}

Main Controller

package app.controllers;

import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;

import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;

public class MainController implements Initializable{
	
	@FXML 
	private BorderPane borderpaneMain;
	@FXML
    private Label label;

	public void getCenter() throws IOException {
		Parent centro = FXMLLoader.load(getClass().getResource("/app/views/btnRecursosHumanos.fxml"));
		borderpaneMain.setCenter(centro);
	}

	@Override
	public void initialize(URL location, ResourceBundle resources) {
		try {
			Parent menulateral = FXMLLoader.load(getClass().getResource("/app/views/MenuLateral.fxml"));
			borderpaneMain.setRight(menulateral);	
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
    
asked by anonymous 07.05.2018 / 22:07

0 answers