Followup: PropertyChangeListener not recognizing changes to a putClientProperty

W

Will

Michael Rauscher wrote on April 29, 2004 (as part of a very helpful
post clarifying the difference between client properties and bound
properties):
The font property e.g. is a so called "bound property". A bound property
is a property that fires PropertyChangeEvents whenever its value is
changed. Class java.beans.PropertyChangeSupport may be used to support
bound properties in your bean.

First of all, thank you for the helpful post -- I'm sorry I missed it
when you originally wrote it, but as far as showing appreciation,
better late than never.

I now have a question about style. If I have an object, let's say,
SpaceShip, with a number of properties, such as power, heading,
location, etc., which are displayed by my UI, and I want the display
updated each time those attributes are updated, is it stylistically OK
to add PropertyChangeSupport to my SpaceShip class, and have the UI
respond to PropertyChangeEvents or would this violate object-oriented
programming principles? (I'm not so conversant with OOP lingo, so I
can't name the principle; it just feels off, somehow.)

Thanks again,

Will
 
C

Chris Riesbeck

I now have a question about style. If I have an object, let's say,
SpaceShip, with a number of properties, such as power, heading,
location, etc., which are displayed by my UI, and I want the display
updated each time those attributes are updated, is it stylistically OK
to add PropertyChangeSupport to my SpaceShip class, and have the UI
respond to PropertyChangeEvents or would this violate object-oriented
programming principles? (I'm not so conversant with OOP lingo, so I
can't name the principle; it just feels off, somehow.)

Yes, this is how you would do it with beans and follow
model-view-controller (MVC) guidelines. Adding property
change support to the model allows observers like views
to register themselves to be notified on changes, without
committing the model to any particular interface, or
to an interface at all.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top