title: JavaFX LineChart - change color of legend which have changed location
body: <p>I have this code:</p>
  
  <pre><code>@Override
  public void start(Stage primaryStage){
  
      NumberAxis xAxis = new NumberAxis();
      xAxis.setLabel("XX");
  
      NumberAxis yAxis = new NumberAxis();
      yAxis.setLabel("YY");
  
      LineChart&lt;Number, Number&gt; lineChart = new LineChart&lt;&gt;(xAxis, yAxis);
  
      XYChart.Series&lt;Number, Number&gt; series1 = new XYChart.Series&lt;&gt;();
      series1.setName("Loooooooooooooongest");
      series1.getData().addAll(new XYChart.Data&lt;&gt;(1, 1));
  
      XYChart.Series&lt;Number, Number&gt; series2 = new XYChart.Series&lt;&gt;();
      series2.setName("Short");
      series2.getData().addAll(new XYChart.Data&lt;&gt;(2, 2));
  
      XYChart.Series&lt;Number, Number&gt; series3 = new XYChart.Series&lt;&gt;();
      series3.setName("Loooooong");
      series3.getData().addAll(new XYChart.Data&lt;&gt;(3, 3));
  
      lineChart.getData().addAll(series1, series2, series3);
      lineChart.setLegendVisible(false); //make default legend invisible
  
      //change color of series
      final AtomicInteger index = new AtomicInteger(0);
      for(int i = 0; i &lt; 3; i++){
  
          int color = (i*60) + 70;
          Platform.runLater(() -&gt;
  
                  lineChart.lookupAll(".series" + index.getAndIncrement())
                          .forEach(e1 -&gt; e1.setStyle("-fx-stroke: rgb(0, 0, " + color + ");" +
                                                      "-fx-background-color: rgb(0, 0, " + color + "), white;"))
  
          );
  
      }
  
      //create an hbox for legends
      HBox legendBox = new HBox();
      legendBox.setStyle("-fx-border-style: solid;" +
                      "-fx-border-color: lightgray;" +
                      "-fx-border-width: 1;" +
                      "-fx-padding: 10;" +
                      "-fx-background-color: white;" +
                      "-fx-alignment: center;");
  
      //take all legends and put in hbox
      var insets = new Insets(0, 10, 0, 10);
      for(Node node : lineChart.lookupAll("Label.chart-legend-item")){
  
          legendBox.getChildren().add(node);
          HBox.setMargin(node, insets);
  
      }
  
      //place chart and hbox-legends in borderpane
      BorderPane borderPane = new BorderPane();
      borderPane.setCenter(lineChart);
      borderPane.setBottom(legendBox);
  
      primaryStage.setScene(new Scene(borderPane));
      primaryStage.sizeToScene();
      primaryStage.centerOnScreen();
  
      primaryStage.show();
  
  }
  </code></pre>
  
  <p>This looks like this:</p>
  
  <p><img src="https://i.imgur.com/0Ssbxuh.png"/></p>
  
  <p>Color of legends are not changed.</p>
  
  <p>If I remove that part with <code>HBox</code> and let legends into original <code>Node</code> their color are change.</p>
  
  <p>Why the color are no longer change if I move legends in other node and how I can change color of legends which are placed in other <code>Node</code> than original?</p>