private void changeText( final @CheckForNull JTextComponent oldTC, final @CheckForNull JTextComponent newTC, final boolean update) { if (newTC == oldTC) return; Document oldDocument = null; if (null != oldTC) { oldTC.removePropertyChangeListener("document", listener); oldDocument = oldTC.getDocument(); } Document newDocument = null; if (null != newTC) { newDocument = newTC.getDocument(); newTC.addPropertyChangeListener("document", listener); } changeDocument(oldDocument, newDocument, update); }