17.6 Using FactoryBuilderSupport
We’ll use FactoryBuilderSupport if we’re working with well-defined node names such as
button, checkbox, label, and so on, in the SwingBuilder. The BuilderSupport we saw in Section 17.5, Using BuilderSupport,
is good for working with hierarchical structures. However, it’s not convenient for
dealing with different types of nodes. Suppose we have to work with twenty different node types. Our
implementation of
createNode
will get complicated. Based on the node name,
we’ll create different nodes, which leads to a messy switch
statement. Chances are we’ll quickly lean toward an abstract factory (see Design Patterns: Elements of Reusable Object-Oriented Software [GHJV95]) approach to create these nodes. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access