title: Full screen under JavaFX with FXML
body: <p>I have already asked the question but it was not answered. </p>
  
  <p>How can I switch to full screen mode in JavaFX by pressing a button? 
  But the button is created with FXML (JavaFX Scene Builder). (cannot find symbol (stage) )
  If the button is created manually, then it works. </p>
  
  <pre><code>public class Buch extends Application implements Initializable
  {
  
  @ Override
      public void start (Stage primaryStage) throws IOException
      {
  
          Stage stage = primaryStage;
  
          Parent root = FXMLLoader.load (getClass () getResource ("Buch.fxml").);
  
          Scene scene = new Scene (root);
  
          stage.setTitle ("Buch");
          stage.setScene (scene);
          stage.getIcons () add (new Image ("Icon.png"));
          / / stage.setFullScreen (true) / / Works
          stage.show ();
  
  
  
      }
  
      @ FXML
      public void fullscreen (ActionEvent event)
      {
  
          / / stage.setFullScreen (true) / / Does not work
          / / cannot find symbol (stage)
  
      }
  </code></pre>
  
  <p>Works: </p>
  
  <pre><code>public class Buch extends Application implements Initializable
  {
  
  @ Override
      public void start (Stage primaryStage) throws IOException
      {
  
          Stage stage = primaryStage;
  
          Parent root = FXMLLoader.load (getClass () getResource ("Buch.fxml").);
  
          Scene scene = new Scene (root);
  
          stage.setTitle ("Buch");
          stage.setScene (scene);
          stage.getIcons () add (new Image ("Icon.png"));
          stage.show ();
  
          btn.setOnAction (new EventHandler &lt;ActionEvent&gt; ()
          {
              public void handle (ActionEvent evt)
              {
                  stage.setFullScreen (true);
              }
  
          });
  
      }
  </code></pre>
  
  <p>Does not work (of course ?): </p>
  
  <pre><code>public class Buch extends Application implements Initializable
  {
  
  @ Override
      public void start (Stage primaryStage) throws IOException
      {
  
          Stage stage = primaryStage;
  
          Parent root = FXMLLoader.load (getClass () getResource ("Buch.fxml").);
  
          Scene scene = new Scene (root);
  
          stage.setTitle ("Buch");
          stage.setScene (scene);
          stage.getIcons () add (new Image ("Icon.png"));
          stage.show ();
  
  * /
         @ FXML
      public void fullscreen (ActionEvent event)
      {
  
          stage.setFullScreen (true) / / Does not work
          / / cannot find symbol (stage)
  
      }
  / * / / Will not work
  
  
      }
  </code></pre>
  
  <p>You can also take a look at this link. The question is more detailed here: </p>
  
  <p>stackoverflow.com/questions/22820049/full-screen-under-javafx-with-fxml-does-not-work </p>
  
  <p>How can I use the stage variable anywhere? Or is there another solution ? 
  Please help me.</p>
  
  <p>On the internet there is NO answer to my question!?! </p>
  
  <p>I am a Java beginner. :-) </p>
  
  <p>Thanks for your help </p>