title: Is a singleton controller possible in JavaFX(ML)?
body: <p>I tried to implement a controller with the singleton pattern like described a couple of times on the web. </p>
  
  <p>However I cant get the application to run because of the following exception.</p>
  
  <pre><code>java.lang.IllegalAccessException: Class sun.reflect.misc.ReflectUtil can not access a member of class testapp.Controller with modifiers "private"
  </code></pre>
  
  <p>I guess thats because the constructor is declared private. I dont see what I am doing wrong at this point. </p>
  
  <p>In case I wasn't clear what my problem is I will describe the use case of what I am going to do.</p>
  
  <p>Inside the <code>start(Stage stage)</code> function afaik is the only place the onclose event can be defined(please correct me if I am wrong). On closing the window some clean-up operations need to be exectued. These operation are inside the controller which I cant get access of in the <code>start() function</code>. Therefore the idea was to build the controller as a singleton to keep one single instance alive and provide acces to the main class.</p>
  
  <p>The Link <a href="https://stackoverflow.com/questions/35565917/creating-a-singleton-controller-class-in-javafx">Creating a Singleton Controller class in JavaFX</a> advised by sillyfly seems not to be a possible sollution for me bacause the controller is passed to a model class not the main class. Also the model constructor is called manually which is not the case I am dealing with.            </p>