It is easy to draw an animation using Java, so that a thread can call itself regularly. Remember to set an exit (end) condition.
Import Org. Eclipse. SWT. SWT; Import Org. Eclipse. SWT. layout. filllayout; Import Org. Eclipse. SWT. Widgets. display; Import Org. Eclipse. SWT. Widgets. shell; Import Org. Eclipse. SWT. Widgets. text; Public Class Animation { Final Static Int Delay= 500 ; Public Static Void Main (string [] ARGs ){ Final Display display = New Display (); Final Shell shell = New Shell (Display); shell. setlayout ( New Filllayout ()); Final Text text = New Text (shell, SWT. Border); text. settext ( "0" ); New Runnable (){ Public Void Run (){ If (Shell. isdisposed ()) Return ; Text. settext ( "" + (Integer. parseint (text. gettext () + 1 ); Display. getdefault (). timerexec (delay, This ) ;}}. Run (); shell. Pack (); shell. open (); While (! Shell. isdisposed ()){ If (! Display. readanddispatch () display. Sleep ();} display. Dispose ();}}
Running result:
Increasing numbers