title: the controller "classname" has no event slot "methodname"
body: <p>I am getting this error   </p>
  
  <p>the controller "classname" has no event slot "methodname"</p>
  
  <p>if i add "/" before application in fx:controller="application.MainController">
  this error goes but creates
  class failed to load </p>
  
  <pre><code>/Users/myname/Documents/workspace/Javafx%20tesr/bin/application/Main.fxml:7
  </code></pre>
  
  <p>here's the xml file </p>
  
  <pre><code> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;?import javafx.scene.control.Button?&gt;
  &lt;?import javafx.scene.control.Label?&gt;
  &lt;?import javafx.scene.layout.AnchorPane?&gt;
  
  &lt;AnchorPane prefHeight="450" prefWidth="500"     xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1"     fx:controller="application.MainController"&gt;
     &lt;children&gt;
        &lt;Button fx:id="genratebutton" layoutX="160.0" layoutY="225.0"     mnemonicParsing="false" onAction="#generaterandom" prefHeight="27.0"     prefWidth="180.0" text="generate random" /&gt;
        &lt;Label fx:id="myMessage" layoutX="138.0" layoutY="104.0"     prefHeight="89.0" prefWidth="225.0" /&gt;
     &lt;/children&gt;
  &lt;/AnchorPane&gt;
  </code></pre>
  
  <p>(sorry new to GUI only know basics of swing) </p>
  
  <p>this is main class </p>
  
  <pre><code>package application;
  
  import javafx.application.Application;
  import javafx.fxml.FXMLLoader;
  import javafx.scene.Parent;
  import javafx.scene.Scene;
  import javafx.stage.Stage;
  
  
  public class Main extends Application {
  @Override
  public void start(Stage primaryStage) {
      try {
  Parent root=FXMLLoader.load(getClass().getClassLoader().getResource("/Main.fxml"));
  
    Scene scene = new Scene(root,400,400);
          scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
          primaryStage.setScene(scene);
          primaryStage.show();
      } 
  
      catch(Exception e) {
          e.printStackTrace();
          System.exit(0);
  
      }
  }
  
  public static void main(String[] args) {
      launch(args);
  }
  }
  </code></pre>
  
  <p>this is another class whose method i want to invoke </p>
  
  <pre><code>package application;
  
  
  import java.util.Random;
  import javafx.event.ActionEvent;
  
  import javafx.fxml.FXML;
  import javafx.scene.control.Label;
  
  
  public class MainController {
  
  @FXML
  private Label myMessage;
  void generaterandom (ActionEvent event){
      Random rand=new Random();
      int myrand=rand.nextInt(50)+1;
      myMessage.setText(Integer.toString(myrand));
      System.out.println(Integer.toString(myrand));
  
  
  }
  
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/eYlwn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eYlwn.png" alt="eclipse explorer view"></a></p>