Is it possible to re-paint an applet without losing its previous contents? I was just trying to make a program which allows users to draw lines, Rectangle etc. using mouse. I have used the repaint method but it does not keep the previously drawn lines/rectangles etc.
Here is the snippet:
public void mousePressed(MouseEvent e){x1=e.getX();y1=e.getY();}
public void mouseDragged(MouseEvent e)
{
x2=e.getX();
y2=e.getY();
repaint();
showStatus("Start Point: "+x1+", "+y1+" End Point: "+x2+", "+y2);
}
public void paint(Graphics g)
{
//g.drawLine(x1,y1,x2,y2);
g.drawRect(x1, y1, x2-x1, y2-y1);
}