I would handle this with ChangeEvent . This is just an indication that something has changed.
How to implement add / remove / fire functionality. A mechanism like PropertyChangeSupport does not exist, but the code is quite simple, and this is not necessary.
private final EventListenerList listenerList = new EventListenerList(); private final ChangeEvent stateChangeEvent = new ChangeEvent(this); public void addChangeListener(ChangeListener l) { listenerList.add(ChangeListener.class, l); } public void removeChangeListener(ChangeListener l) { listenerList.remove(ChangeListener.class, l); } protected void fireChange() { for (ChangeListener l: listenerList.getListeners(ChangeListener.class)) { l.stateChanged(stateChangeEvent); } }
Note. JComponent provides a protected listenerList object for use by subclasses.
Devon_c_miller
source share