-
Book Overview & Buying
-
Table Of Contents
Eclipse Plug-in Development Beginner's Guide - Second Edition
By :
To execute code on the UI thread, Runnable instances must be posted to the Display via one of two methods, syncExec or asyncExec. The syncExec method runs the code synchronously (the caller blocks until the code has been run) while the asyncExec method runs the code asynchronously (the caller continues while the code is run in the background).
The Display class is SWT's handle to a monitor (so a runtime may have more than one Display object, and each may have its own resolution). To get hold of an instance, call either Display.getCurrent() or Display.getDefault(). However, it's much better to get a Display from an associated view or widget. In this case, the Canvas has an associated Display.
Go to the TickTock thread inside the createPartControl method of the ClockView class.
Inside the redraw lambda, replace the call to clock.redraw() with this:
// clock.redraw(); clock.getDisplay().asyncExec(() -> clock.redraw());
Run the target Eclipse instance...
Change the font size
Change margin width
Change background colour