void (PropertyChangeEvent event) { Object oldValue = event.getOldValue(); if (oldValue instanceof TreeModel) ((TreeModel)oldValue).removeTreeModelListener(myTreeModelListener); Object newValue = event.getNewValue(); if (newValue instanceof TreeModel) ((TreeModel)newValue).addTreeModelListener(myTreeModelListener); }