The second hand is drawn with a redraw
on the Canvas
, but this will need to be run periodically. If it is redrawn once per second, it can emulate a clock ticking.
Eclipse has a jobs
plug-in, which would be just right for this task, but this will be covered in Chapter 4, Interacting with the User. So to begin with, a simple Thread
will be used to issue the redraw.
Open the
ClockView
class.Add the following at the bottom of the
createPartControl
method:Runnable redraw = () -> { while (!clock.isDisposed()) { clock.redraw(); try { Thread.sleep(1000); } catch (InterruptedException e) { return; } } }; new Thread(redraw, "TickTock").start();
Relaunch the test Eclipse instance, and open the Clock View.
Open the host Eclipse instance and look in the Console View for the errors.