first_page

Canvas over UIComponent

Buy this book at Amazon.com!It turns out that UIComponent is too ‘low level’ for acting as a parent container of child objects. This becomes apparent when the UIComponent (acting as a parent) becomes itself a child of another container. The alternative is to use Canvas.

So my earlier journal entry heaping praise on UIComponent failed to see the situation when hierarchies of visual components are in the design. This learning experience might find me telling the truth when I say that Canvas is ‘optimized’ for an absolute positioned layout (and stacking objects) while Box is designed for the “flow” layout made popular by HTML.

My new declaration is that there is one (of many) relationship among UIComponent, Graphics, Canvas and any subclass of Container. Draw vectors with Graphics property of one or more UIComponent objects. Composite (swap the z-order) of these UIComponent objects on an instance of Canvas. When the paint dries, slide the Canvas into a subclass of Container.

rasx()