0

I have two controllers. They both inherit from the Application class. The first window/controller loads when the application starts, the second window/controller loads when a button is clicked. It works, except for this question:

What is the entry point of the second window/controller? In the first controller I can put code in the start method but that method in the second window/controller does not get called.

This code runs in the first controller to launch the second controller:

try {
    FXMLLoader fxmlLoader = null;
    // Open the New Process A Query Window
    fxmlLoader = new FXMLLoader(getClass().getResource("processAQuery.fxml"));
    Parent root = fxmlLoader.load();
    Stage stage = new Stage();
    stage.setScene(new Scene(root, 988, 833));
    stage.show();
} catch (Exception ex) {
    // ...
}

I am using SceneBuiler to create the FXML.

nicomp
  • 4,344
  • 4
  • 27
  • 60
  • 2
    Your controllers should not be subclasses of `Application`, and you should only have one `Application` subclass class in your application. – James_D Jun 27 '17 at 15:10
  • What does the second controller inherit from? – nicomp Jun 27 '17 at 15:11
  • 1
    Neither controller should really inherit from anything. Again, don't use the `Application` class as a controller class. See https://stackoverflow.com/questions/32081713/javafx-controller-class-not-working and https://stackoverflow.com/questions/33303167/javafx-can-application-class-be-the-controller-class (among others) – James_D Jun 27 '17 at 15:11
  • "In the first controller I can put code in the start method" : the `start()` method is not called on the controller, it is called on the `Application` instance created when the application is launched (and started...). And didn't you essentially [already ask this question](https://stackoverflow.com/questions/44343826/what-event-fires-after-a-form-is-initially-loaded)? – James_D Jun 27 '17 at 15:14
  • Ow. I duplicated myself. – nicomp Jun 27 '17 at 15:52

0 Answers0