Is there a standard Java interface for "implements addActionListener", "implements addChangeListener", etc.?
Posted on 2014-11-13
Is there a standard Java interface for "implements addActionListener", "implements addChangeListener", "implements AddPropertyChangeListener"?
Say I create a new component, and this new component has a JButton and let's say a JSpinner configured to show numeric values, the JButton creates an Action, and the JSpinner is a property who's value changes, so I expect the user to call addActionListener to know when the button is pressed, and addPropertyChangeListener to know when the value of the JSpinner has changed.
Are there standard interfaces I should have my component implement that says, "This component supports addActionListener", and "This component supports addPropertyChangeListener"?
If the answer is "No", which I suspect is the case, then my next question is, "Why not?"
When I look at a class and I want to know what calls this class supports, I look at the interfaces. If there's no interface telling me "This class supports addActionListener", then it seems like I'm just supposed to magically "know" this (perhaps by reading the unwritten documentation?)
So, where am I going wrong in my thinking here?