javamonkey79
javamonkey79

Reputation: 17765

general way to listen to all change events on swing objects

Is there a library or technique to listen to all changeable events on swing ui objects? Specifically the data.

For instance, I have a JPanel with a JTextArea, JCheckBox, JComboBox, etc. Is there a common way to say "If the data in this changes, notify me"? I don't care about borders changing, and other UI event stuff, just user data changing.

I've tried propertychangelister, but I can't seem to find a common property, or a common class that will do this.

Upvotes: 2

Views: 113

Answers (1)

trashgod
trashgod

Reputation: 205785

No, nothing common. You can listen directly to the model for those components that have a separable model. You can wrap the change in a PropertyChangeListener, as shown here, in order to customize the message. The observer pattern is mentioned here.

Upvotes: 3

Related Questions