/** * This method is called by the toolkit when the component is removed. Used as a hook to decrement * ReplDocument's reference count, and maybe close the document. */ @Override public void removeNotify() { super.removeNotify(); if (--document.paneCount == 0) document.close(); }