Setting a color for a specific series in javafx
<p>I'm writing a program in javafx where I'm comparing different companies and products to each other using bubble charts, line charts, scatter charts and pie charts. I would like one certain company and all products belonging to it to always have the color green when appearing in the charts. Right now I'm using css to style the charts and I've tried these different alternatives for setting a color for a specific series (in this case it's for the bubble charts):</p>

<pre><code>if(company.equals("MyCompany")) {
     //alternative 1
     Set&lt;Node&gt; nodes = series.getNode().lookupAll("chart-bubble");
     for(Node node : nodes) {
        node.getStyleClass().add("myCompany-chart-bubble");
     }

     //alternative 2
     series.nodeProperty().get().setStyle("-fx-bubble-fill:  #7fff00;");

     //alternative 3
     series.getData().get(0).getNode().getStyleClass().add("myCompany-chart-bubble");

     //alternative 4
     series.getNode().getStyleClass().add("myCompany-chart-bubble");
}
</code></pre>

<p>All these alternatives give NullPointerExceptions. Why is that? Is there any other way I can set the color the way I would like to?</p>

<p>Thanks!</p>