title: Javafx 2.0 How-to Application.getParameters() in a Controller.java file
body: <p>Considering the following sample.</p>
  
  <p><em><strong>How to access to arguments/parameters of the application in the controller?</em></strong></p>
  
  <p>Thank you.</p>
  
  <hr>
  
  <p><em>NB: I've tried to mix App.java and MyController.java in only one Class file, but didn't help.</em></p>
  
  <hr>
  
  <p><strong>App.java (simplified):</strong></p>
  
  <pre><code>public class App extends Application {
  
      public static void main(String[] args) {
          Application.launch(App.class, args);
      }
  
      @Override
      public void start(Stage primaryStage) throws Exception {
  
          // output arguments in console
          System.out.println(getParameters().getNamed().toString());
  
          Parent root = FXMLLoader.load(getClass().getResource("MyView.fxml"));
          final Scene scene = new javafx.scene.Scene(root);
          primaryStage.setScene(scene);
          primaryStage.show();
      }
  
  }
  </code></pre>
  
  <p><strong>MyController.java (simplified):</strong></p>
  
  <pre><code>public class MyController implements Initializable {
  
      @Override
      public void initialize(URL url, ResourceBundle rb) {
          // HOW TO getParameters() HERE ?
      }
  
      @FXML
      private Button myButton;
  
      @FXML
      private void my_Action(ActionEvent event) {
          // HOW TO getParameters() HERE ?
      }
  
  }
  </code></pre>
  
  <p><strong>MyView.fxml (simplified):</strong></p>
  
  <pre><code>&lt;AnchorPane fx:id="root" fx:controller="mainpackage.MyController"&gt;
      &lt;children&gt;
          &lt;Button fx:id="myButton" onAction="#my_Action" text="Start" /&gt;
      &lt;/children&gt;
  &lt;/AnchorPane&gt;
  </code></pre>