Maintaining an Observable Object

You may not always be able to make the class you want to observe a subclass of Observable. In particular, your class may already be a subclass of something other than Object. In this case, you can provide your class with an Observable object and have your class forward key method calls to it. The Component class in java.awt uses this approach, although it uses a PropertyChangeSupport object instead of an Observable object.

The PropertyChangeSupport class is quite similar to the Observable class but is part of the java.beans package. The JavaBeans API exists to support the creation of reusable components. This API has found its greatest applicability to GUI components, but you can certainly apply it elsewhere. ...

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.