title: Run method from controller class on startup Javafx
body: <p>I got a javafx application and I got a main where I set up my stage and launch the application. I also have a controller class:</p>
  
  <pre><code>public class Controller
  {    
      @FXML Button button;
      public void test(){
          button.setText("Button");
      }
  }
  </code></pre>
  
  <p>How would I go about running the test method on startup. I know I can create an instance in the main class...</p>
  
  <pre><code>public class Main extends Application{
     public void start(Stage primaryStage) throws Exception {
        ...
  
     public static void main (String[] args){
          launch (Main.class);
          Controller cont = Controller();
          cont.test();
     }
  }
  </code></pre>
  
  <p>and that would work. However it is not ideal for me. I was wondering if it was possible to run the method directly from the controller class, if not is there a better way of handling this? Thanks</p>