Forum Stats

  • 3,840,393 Users
  • 2,262,599 Discussions
  • 7,901,262 Comments

Discussions

Load Exception??

3463663
3463663 Member Posts: 7
edited May 11, 2017 5:20PM in JavaFX 2.0 and Later

Hi all,

I am facing this problem,

Caused by: javafx.fxml.LoadException: Error resolving onAction='#MakeNewProject', either the event handler is not in the Namespace or there is an error in the script.

On button click, I face this problem.  I write the following code,

  @FXML

    private void handleButtonAction(ActionEvent event) throws IOException {

        if(event.getSource()==btnEnglish)

        {

              Parent root = FXMLLoader.load(getClass().getResource("/fxml/View_homescreen.fxml"));

       

       Stage addDialogStage=new Stage();

       addDialogStage.setTitle("Home Screen");

       addDialogStage.initModality(Modality.APPLICATION_MODAL);

    

      

       Scene scene=new Scene(root);

       scene.getStylesheets().add("/styles/Style_selectlanguage.css");

       addDialogStage.setScene(scene);

       addDialogStage.showAndWait();

        }

How do we solve this problem?

Answers

  • bouye-JavaNet
    bouye-JavaNet Member Posts: 394 Silver Badge
    edited May 11, 2017 5:20PM

    Well if the piece of code is from the controller of the FXML you are attempting to load, the FXML indicated it needs a method called MakeNewProject() but your method is called handleButtonAction(), so...

    If it's not from the controller for that particular FXML, check that controller code for mistype or spelling error in the handler name (or event if it exists in the first place)...

This discussion has been closed.