I have a JavaFX Group
with a Path
Node added to it, to which I add data approximately 30 times per second. This causes my whole GUI to become very laggy and unresponsive after about a minute.
First, I add the path to the Group
like this:
root.getChildren().add(path);
Data is added like this:
while(true) {
// Calculate x and y...
path.getElements().add(new LineTo(x, y));
path.getElements().add(new MoveTo(x, y));
// Sleep 33 milliseconds...
}
If I do not add the path to the group, but still add data afterwards, the GUI remains responsive, so the performance issue seems to be when drawing the path's shape. Why? What can I do to improve the performance? Is this known to happen or am I doing something wrong? Thanks!