How do I fix my MS-Paint clone

Question from CONNOR#1257

Hello, I am trying to make an application similar to ms paint.

When I add super.paint(g) to my paint method my panel appears, however, when I start drawing the lines keep disappearing. when I remove the super.paint(g) the panel is no longer visible but the drawing works perfectly fine.

Your issue is this:

If you call super.paint(g) it will clear the screen. It then expects you to draw every point.

If you don't call super.paint(g) then the panel isn't redrawn, but whatever paints you have from previous render cycles are left.

The solution is to remember what has been drawn so far and just draw it on the screen again every time you re-render.

The easiest way to do this might be to have a 2d array of java.awt.Color.

When you draw update that array, and when you re-render just write every color to the screen.


<- Index