Overriding update . . .
public class buff extends Applet {
int x=10, y=10, dx=1, dy=2;
public void init(){super.init();}
public void paint (Graphics g){
g.setColor(Color.gray); g.fillRect(0,0, getSize().width, getSize().height); g.setColor(Color.red); g.fillOval(x,y, 10,10);
x+=dx; y+=dy; if (x>= getSize().width-10 || x <=10) dx*=-1;
if (y>= getSize().height-10 || y <=10) dy*=-1;
public void update(Graphics g)