title: How to add a group to the scene in JavaFX?
body: <p>FXML document:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;?import java.lang.*?&gt;
  &lt;?import java.util.*?&gt;
  &lt;?import javafx.scene.*?&gt;
  &lt;?import javafx.scene.control.*?&gt;
  &lt;?import javafx.scene.layout.*?&gt;
  &lt;?import java.net.URL?&gt;
  
  &lt;AnchorPane id="AnchorPane" fx:id="apMain" prefHeight="600" prefWidth="600" xmlns:fx="http://javafx.com/fxml/1" fx:controller="funkcje.FXMLDocumentController"&gt;
       &lt;stylesheets&gt;
      &lt;URL value="@style.css" /&gt;
      &lt;/stylesheets&gt;
      &lt;children&gt;
          &lt;Button prefHeight="20" prefWidth="70" layoutX="265" layoutY="550" text="Narysuj" onAction="#handleButtonAction" fx:id="button" /&gt;
          &lt;Label layoutX="30" layoutY="500" minHeight="16" minWidth="69" text="Podaj A:" fx:id="labelA" /&gt;
          &lt;TextField layoutX="105" layoutY="503" prefHeight="20" prefWidth="90" fx:id="textfieldA" /&gt;
          &lt;Label layoutX="200" layoutY="500" minHeight="16" minWidth="69" text="Podaj B:" fx:id="labelB" /&gt;
          &lt;TextField layoutX="275" layoutY="503" prefHeight="20" prefWidth="90" fx:id="textfieldB" /&gt;
          &lt;Label layoutX="370" layoutY="500" minHeight="16" minWidth="69" text="Podaj miare:" fx:id="labelC" /&gt;
          &lt;TextField layoutX="483" layoutY="503" prefHeight="20" prefWidth="90" fx:id="textfieldC" /&gt;
      &lt;/children&gt;
  &lt;/AnchorPane&gt;
  </code></pre>
  
  <p>FXML controller:</p>
  
  <pre><code>    package funkcje;
  
      import java.net.URL;
      import java.util.ResourceBundle;
      import javafx.event.ActionEvent;
      import javafx.fxml.FXML;
      import javafx.fxml.Initializable;
      import javafx.scene.Group;
      import javafx.scene.control.Label;
      import javafx.scene.layout.AnchorPane;
      import javafx.scene.layout.Pane;
      import javafx.scene.paint.Color;
      import javafx.scene.shape.Line;
      import javafx.scene.shape.Rectangle;
  
      /**
       *
       * 
       */
      public class FXMLDocumentController implements Initializable {
  
          @FXML
          private Label label;
          private AnchorPane apMain;
  
          @FXML
          private void handleButtonAction(ActionEvent event) {
              System.out.println("You clicked me!");
              label.setText("Hello World!");
          }
  
          @Override
          public void initialize(URL url, ResourceBundle rb) {
              // TODO
              Group group = new Group();
              Rectangle r2 = new Rectangle(250, 25, 100, 140);
              r2.setStroke(Color.BLACK);
              r2.setFill(null);
              r2.setStrokeWidth(3);
              r2.setArcWidth(25);
              r2.setArcHeight(25);
              group.getChildren().add(r2);
  
              apMain.getChildren().add(group);
  
          }    
  
      }
  
  main app:
  
  /*
   * To change this license header, choose License Headers in Project Properties.
   * To change this template file, choose Tools | Templates
   * and open the template in the editor.
   */
  package funkcje;
  
  import javafx.application.Application;
  import javafx.fxml.FXMLLoader;
  import javafx.scene.Group;
  import javafx.scene.Parent;
  import javafx.scene.Scene;
  import javafx.scene.layout.AnchorPane;
  import javafx.scene.paint.Color;
  import javafx.scene.shape.Line;
  import javafx.scene.shape.Rectangle;
  import javafx.stage.Stage;
  
  /**
   *
   *
   */
  public class Funkcje extends Application {
  
      @Override
      public void start(Stage stage) throws Exception {
          Parent root = FXMLLoader.load(getClass().getResource("FXMLDocument.fxml"));
          Scene scene = new Scene(root);
          stage.setResizable(false);
          stage.setTitle("Funkcje");
          stage.setScene(scene);
          stage.show();
      }
  
      /**
       * @param args the command line arguments
       */
      public static void main(String[] args) {
          launch(args);
      }
  
  }
  </code></pre>
  
  <p>Here it is. Help me.
  There's some text, I cant post it, because I have too much code and less text.
  Here it is. Help me.
  There's some text, I cant post it, because I have too much code and less text.
  Here it is. Help me.
  There's some text, I cant post it, because I have too much code and less text.
  Here it is. Help me.
  There's some text, I cant post it, because I have too much code and less text.</p>