Mediator (Chapter 10)
SOLUTION 10.1 | Figure 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 ... |
Get Design Patterns Java™ Workbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.