I’m going to write some code using the Eclipse SWT. I want a window that will show a grid of colored squares. I was thinking I would extend the Canvas widget and draw on that.
In the Programmer’s Guide it suggests wrapping a widget. “To wrap a widget, you create a subclass of the…Canvas widget”. Then later it says “Extending a widget by subclassing it is highly discouraged, since it will make your widget dependent on the implementation of the superclass.” A bit contradictory. So apparently, I want to wrap the widget without subclassing it. How? The design patterns Adaptor and Decorator don’t fit with what I want to do.