i paint the square at x,y and then increment x and y in the run method before repainting but the square doesnt move
import java.applet.*;
import java.awt.*;
public class Basics extends Applet implements Runnable{
int x = 0;
int y = 0;
public void init(){
setSize(500,500);
}
public void start(){
Thread a = new Thread();
a.start();
}
public void stop(){
}
public void destroy(){
}
public void run(){
while(true){
x++;
y++;
repaint();
try{
Thread.sleep(18);
}
catch(InterruptedException e){}
}
}
public void paint(Graphics g){
g.setColor(Color.red);
g.fillRect(x,y,25,25);
}
}
however, even if i dont increment x and y and just set a value for them in the run method the square paints at 0,0;