FXML Loader error

Asked

Viewed 91 times

1

The goal in the code was that by clicking the + button would be shown the screen of the Establishment that is in the file Telaesbelecimento.fxml but errors are occurring.

SCREEN CODE CONSULT

import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.AnchorPane;

/**
 * FXML Controller class
 *
 * @author arthu
 */
public class ConsultaController implements Initializable {


    /**
     * Initializes the controller class.

     */
    /*
    @FXML
    private Label labelexem;
    @FXML
    */
    @FXML
    private Button botSair;
    @FXML

    private Button botVoltar;

    @FXML
    private Button botFrame1;
    /*
    @FXML
    private Button botFrame2;
    @FXML
    private Button botFrame3;
    @FXML
    private Button botFrame4;
    */
    @FXML
    private AnchorPane anchor;

    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }    
    public void handleBotSair(ActionEvent e){
        System.exit(0);
    }

     public void handleBotVoltar(ActionEvent e) throws IOException{
         AnchorPane a = (AnchorPane)FXMLLoader.load(getClass().getResource("Main.fxml"));
         anchor.getChildren().setAll(a);
    }

     public void handleBotFrame1(ActionEvent e) throws IOException{
         AnchorPane g = (AnchorPane)FXMLLoader.load(getClass().getResource("TelaEstabelecimento.fxml"));
         anchor.getChildren().setAll(g);
    }

}

STORE SCREEN CODE

import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.AnchorPane;

/**
 * FXML Controller class
 *
 * @author arthu
 */
public class TelaEstabelecimentoController implements Initializable {

    /**
     * Initializes the controller class.
     */

    @FXML 
    private Button botSair;
    @FXML 
    private Button botVoltar;
    @FXML
    private AnchorPane ancho;

    @Override
    public void initialize(URL url, ResourceBundle rb) {
        // TODO
    }    

    public void handleBotSair(ActionEvent e){
        System.exit(0);
    }


}

Can someone point me in the wrong direction ?

1 answer

0

Change anchor.getChildren().setAll(g); for anchor.getChildren().add(g);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.