This discussion is archived
2 Replies Latest reply: Jan 7, 2013 4:36 AM by 898076 RSS

How to empty canvas, in order to reuse it?

898076 Newbie
Currently Being Moderated
Can Canvas be reused multiple times? I tried the following:
        GraphicsContext gc = canvas.getGraphicsContext2D();
        gc.setFill(Color.TRANSPARENT);
        gc.clearRect(0, 0, frameWidth, frameHeight);
before drawing each new set of lines, but sooner or later the following exception is thrown:
java.lang.InternalError: Unrecognized PGCanvas token: 67
     at com.sun.javafx.sg.prism.NGCanvas.renderStream(NGCanvas.java:753)
     at com.sun.javafx.sg.prism.NGCanvas.renderContent(NGCanvas.java:244)
     at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:187)
     at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:39)
     at com.sun.javafx.sg.BaseNode.render(BaseNode.java:1133)
     at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:204)
     at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:187)
     at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:39)
     at com.sun.javafx.sg.BaseNode.render(BaseNode.java:1133)
     at com.sun.javafx.sg.prism.NGGroup.renderContent(NGGroup.java:204)
     at com.sun.javafx.sg.prism.NGRegion.renderContent(NGRegion.java:420)
     at com.sun.javafx.sg.prism.NGNode.doRender(NGNode.java:187)
        ...
despite everything scene-related being run on FX2 thread.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points