To show the effect of changing the TimeZone
, it is necessary to add an hour hand to the clock. When the time zone is changed in the drop-down box, the hour hand will be updated.
Add an
offset
field toClockWidget
along with a setter:private int offset; public void setOffset(int offset) { this.offset = offset; }
Getters and setters can be generated automatically. Once the field is added, the Source | Generate Getters and Setters menu option can be used to generate all missing getters and/or setters; in addition, a single getter/setter can be generated by typing
set
in the class body, followed by Ctrl + Space (Cmd + Space on OS X).Add an hour hand in the
paintControl()
method using the following:e.gc.setBackground(e.display.getSystemColor(SWT.COLOR_BLACK)); int hours = new Date().getHours() + offset; arc = (3 - hours) * 30 % 360; e.gc.fillArc(e.x, e.y, e.width-1, e.height-1, arc - 5, 10);
To update the clock when the time zone is changed, register a
SelectionListener...