I am having a grid of buttons and I want to draw a line between any two clicked buttons and that line should stay when i press next set of buttons.To do so I made following paint and init method in applet and also override the update method because we know that first of all repaint calls the update(Graphics g) method. default implementation of upadate is that it first clears the background and then calls the paint method which finally does the drawing . and hence due to the default implementation of the update method previous drawing gets erased. if we override the update method as given then it calls paint(g) directly and hence does not clear the earlier drawing.
But still the previous line disappear.