4.3. Extending an existing widget
GWT is Java, so creating a new widget that’s based on an existing widget is merely a case of subclassing that existing widget and overriding and adding the methods you need. For example, GWT’s own Canvas widget extends FocusWidget and adds all the canvas functionality it needs. The benefit in doing that is that FocusPanel is a simple div element that holds one widget but also already provides code for all the MouseHandler handlers.
We’ll show you how to create a new label-type widget that reports its dimensions once it’s attached to the DOM—the ReportSizeLabel widget—by extending the existing InlineLabel widget. To get there, we’ll take the next two sections to introduce it, and as in the previous approach, ...
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.