title: How can I access a Controller class in JavaFx 2.0?
body: <p>Recently I was programming a software with JavaFx2.0,but I met with a big problem,that is - How can I access a Controller class?
  For every controller class with the same class type,they may act different because of the model it depends on,so I want to get
  the view's Controller class and provide it with the specified model,can I do this?
  I have tried to get the controller by the FXMLLoader,but the method getController() returns null!why?</p>
  
  <p>1.LightView.java</p>
  
  <pre><code>FXMLLoader loader = new FXMLLoader();
  anchorPane = loader.load(LightView.class.getResource(fxmlFile));//fxmlFile = "LightView.fxml"
  //controller = (LightViewController) loader.getController();//fail to get controller!it is null
  //I want to -&gt; controller.setLight(light);
  </code></pre>
  
  <p>2.LightView.fxml</p>
  
  <pre><code>&lt;AnchorPane ... fx:controller="light.LightViewController" &gt;
  </code></pre>
  
  <p>3.LightViewController.java</p>
  
  <pre><code>....
  private Light light;
  public void initialize(URL arg0, ResourceBundle arg1)
  </code></pre>
  
  <p>4.Light.java</p>
  
  <pre><code>.... a simple pojo
  </code></pre>
  
  <p>so,what I want to do is provide every LightViewController with a specified Light Object(they are from a List).
  Can anyone helps me?Thanks a lot!</p>