When the user clicks on the icon, nothing happens. That's because there is no registered listener on the TrayItem
itself. There are two listeners that can be registered; a SelectionListener
, called when the icon is clicked, and a MenuDetectListener
, which can respond to a context-sensitive menu. The former will be used to present a clock in its own window, which in SWT terms is called a Shell
.
Open the
Activator
class.Go to the lambda inside the
asyncExec
in theActivator
class'sstart
method.After the creation of the
TrayItem
, calladdSelectionListener
with a new anonymous inner subclass ofSelectionListener
. In thewidgetSelected
method, anew Shell
should be created with aClockView
and then shown:trayItem.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { Shell shell = new Shell(display); shell.setLayout(new FillLayout()); new ClockWidget(shell, SWT.NONE, new RGB(255, 0, 255)); shell.pack...