Lines 13 - 27 of the RectangleComponentViewer class create a listener to control mouse press events on the RectangleComponent.
Lines 29 - 30 create a listener of this class and add this listener to the RectangleComponent.
So the model (RectangleComponent) is primarily the data, but through inheritance from JComponent it can be connected to views and controllers:
- a JComponent subclass can override paintComponent to be able to draw itself when asked to do so by a view (e.g., a JFrame with possibly other components).
- a JComponent subclass inherits a list to hold event handlers. So event handlers to control the component can be added.