Like this article? We recommend
Refreshing the View
To refresh the view, you can use the TimerTask to call the repaint() method of the canvas. Another way is to use Thread directly and make the ExampleCanvas (the name of the canvas class) to implement the Runnable interface.
Listing 4. Refreshing the view
private class RefreshTask extends TimerTask { public void run(){ if(myCanvas != null && myGraphics3D != null && myWorld != null) { int startTime = (int)System.currentTimeMillis(); int validity = myWorld.animate(startTime); myCanvas.repaint(viewport_x, viewport_y, viewport_width, viewport_height); } } }