To allow the time zone of the clock widgets to be changed, a drop-down box (known as Combo
) as well as a Button
will be added to the view. The Combo
will be created from a set of ZoneId
instances.
Create a
timeZones
field in theClockView
class:private Combo timeZones;
At the end of the
createPartControl
method, add this snippet to create the drop-down list:public void createPartControl(Composite parent) { ... timeZones = new Combo(parent, SWT.DROP_DOWN); timeZones.setVisibleItemCount(5); for (String zone : ZoneId.getAvailableZoneIds()) { timeZones.add(zone); } }
Run the target Eclipse and open the Clock View again; a list of time zone names will be shown in a drop-down:
It's conventional to set the focus on a particular widget when a view is opened. Implement the appropriate call in the
ClockView
methodsetFocus
:public void setFocus() { timeZones.setFocus(); }
Run Eclipse and show the Clock View; the time zone drop-down widget will be focused...