//########################################################################################################### /*** stat method ***/ public void start() { Thread thread = new Thread(this); //set up thread thread.start(); //start thread jump inside run method }/*** end of start method ***/ //########################################################################################################### /*** run method ***/ public void run() { while(true) //main game loop { //move image here x += dx; if(x+width >= getWidth()) { x -= dx; } repaint(); try { Thread.sleep(17); } catch(InterruptedException e) { e.printStackTrace(); } }//end of while loop }/*** end of run method ***/
i want to keep same structure but replacing thread with timer.
in start method i can set and start timer.
public void start() { Timer timer = new Timer(17,this); timer.start(); }/*** end of start method ***/
but not sure about run method bc run method it is thread method.