Using Events with CoolBars

Unlike ToolItem, no events are associated directly with a CoolItem. Rather, events are associated with the widget that is assigned to the CoolItem.

How do I do that?

Example 15-1 assigns a SelectionListener to each Button to handle the event caused by the user clicking the button:

openBtn.addSelectionListener(new SelectionAdapter( ) {
       public void widgetSelected(SelectionEvent event) {
           System.out.println("Open");
       }
});

Get SWT: A Developer's Notebook 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.