O'Reilly logo

Design Patterns Java™ Workbook by Steven John Metsker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Extending with Visitor

Suppose that you accept an assignment to help bring up a new Oozinoz factory in Dublin, Ireland. The developers in Dublin have created an object model of the new factory's machine composition and have made this model accessible as the static dublin() method of the OozinozFactory class. To display this composite, the developers created a MachineTreeModel class to adapt the model's information to a JTree object's needs. (The code for the MachineTreeModel class is in the com.oozinoz.dublin package.) Displaying the new factory's machines requires building an instance of MachineTreeModel from the factory composite and wrapping this model in Swing components:

 package com.oozinoz.applications; import javax.swing.*; import javax.swing.tree.*; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required