14.6. Creating your own events
The great thing with the current approach to GWT events is that you can create your own events and have them handled in exactly the same way as all other GWT events. Unfortunately, you have to write a disproportionate amount of code: the event, a handler, and another interface! Maybe the Google Plugin for Eclipse will someday have a wizard, but for now it’s all by hand.
In this section we’ll create a logical event to indicate a change of color, which we’ll use in the next section about EventBus. The act of creating a user-defined event is simple, but it’s a bit cumbersome and open to a lot of opportunity for typing something wrong. Creating a user-defined event involves defining things in two steps:
- The event ...
Get GWT in Action, 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.