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

Mediator (Chapter 10)

SOLUTION 10.1Figure B.12 shows a solution. The arrowheads in the link between PlaceA-Tub and PlaceATubMediator emphasize two-way navigability between these classes. A PlaceATub object has a mediator that it registers for events:
public JTextField textField()
{
    if (textField == null)
    {
        textField = new JTextField();
        textField.setFont(font());
        textField.addActionListener(mediator());
        textField.addFocusListener(mediator());
    }
    return textField;
}
Figure B.12. The PlaceATub class handles component building, and the PlaceATubMediator class handles events.

The constructor for PlaceATubMediator accepts a PlaceATub object to which ...

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