public void run() { int the_width = size().width; int flag = 0; while(animazione != null) { if (flag == 0) { x+=1; if (x == (size().width) - (r *2)) { flag = 1; } } if (flag == 1) { x-=1; if (x==0) { flag = 0; } } repaint(); try { Thread.sleep(10);} catch (InterruptedException e) { } } }