I want to create a class that extends JFXPanel to handle a line chart, and integrate this JFXPanel with my application made ​​in Java SE, I also pass data to the graph in real-time from my JFrame application.

Here is my example code:

```
    public class LineChartJFXPanel extends JFXPanel {

        private final LineChart<Number,Number> chart;
        private final HashMap<String,  XYChart.Series<Number,Number>> series;
        private final NumberAxis xAxis, yAxis;

        public LineChartJFXPanel() {
            Platform.setImplicitExit(false);
            series = new HashMap<>();
            xAxis = new NumberAxis(0.0,10.0,1.0);
            yAxis = new NumberAxis(0.0,10.0,1.0);
            chart = new LineChart<>(xAxis,yAxis);
            setScene(new Scene(chart));
        }

        public void setSeries(String idSeries, String nameSeries, Number xIni, Number yIni){
            XYChart.Series<Number,Number> newSeries = new XYChart.Series<>();
            newSeries.setName(nameSeries);
            newSeries.getData().add(new XYChart.Data<>(xIni,yIni));
            chart.getData().add(newSeries);
            series.put(idSeries, newSeries);
        }
    }

******************************************

    public class PanelChart extends JPanel{

        LineChartJFXPanel lineChart;

        public PanelChart(){
            setLayout(new GridLayout(1, 2));
            lineChart =  new LineChartJFXPanel();
            add(lineChart);
        }
    }

********************************

    public class Main extends JFrame{
        PanelChart chartPanel;
        public Main(){
            setPreferredSize(new Dimension(800, 600));
            chartPanel = new PanelChart();
            getContentPane().add(chartPanel);
            setVisible(true);
        }

        public static void main(String args[]){
            Main main = new Main();
            main.setVisible(true);
        }

    }

```

But when I run the code, it shows me the following error:

```
Exception in thread "main" java.lang.IllegalStateException: Not on FX application thread; currentThread = main

at com.sun.javafx.tk.Toolkit.checkFxUserThread(Toolkit.java:237)
at com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(QuantumToolkit.java:400)
at javafx.scene.Scene.<init>(Scene.java:290)
at javafx.scene.Scene.<init>(Scene.java:198)
at javachartdemo.LineChartJFXPanel.<init>(LineChartJFXPanel.java:39)
at javachartdemo.PanelChart.<init>(PanelChart.java:22)
at javachartdemo.Main.<init>(Main.java:21)
at javachartdemo.Main.main(Main.java:27)

```

What do I need to change in my application?