I tried to add a event listener to a container like JTextPane , when before removed a component ,that I can check the component's name and decide the component should be removed or not. I search the answer,there is a Container Listener ,it has the method componentRemoved,but it fired after component removed.so ,Any one has some solution?Any suggestion will be appreciated.I tried to add a event listener to a container