First it will be better using gc.strokeLine(x1, y1, x2, y2);
To clear the line itself you could clear a rect around the line like gc.clearRect(x1 - 1, y1 - 1, x2 + 1, y2 + 1); Take a look at this Gist... https://gist.github.com/HanSolo/f25412352ff7ec5b9b53 <https://gist.github.com/HanSolo/f25412352ff7ec5b9b53> > Am 04.02.2016 um 08:53 schrieb Bryan Buchanan <bry...@webbtide.com>: > > Don't know if this is correct mailing list. > > If I have > > gc.setStroke(Color.RED); > gc.moveTo(x1, y1); > gc.lineTo(x2, y2); > gc.stroke(); > > and later I want to remove this line, how do I do that ? > > I don't want to clear the whole the Canvas (in fact > > gc.clearRect(0, 0, canvas.getWidth(), canvas.getHeight()); > > doesn't remove the line anyway). > > Also, if I wanted to implement a blinking cursor on a Canvas, is there a > neat way to do that ? > > Thanks.