Time for action – getting in focus

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.

  1. Create a timeZones field in the ClockView class:
    private Combo timeZones;
  2. 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);
      }
    }
  3. Run the target Eclipse and open the Clock View again; a list of time zone names will be shown in a drop-down:
  4. It's conventional to set the focus on a particular ...

Get Eclipse Plug-in Development Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.