Listening for new child components in Swing

I have a special requirement that all children of a particular JComponent disable double buffering. I can go through this quite easily and disable them when necessary, but I would like to detect the addition of new components for children regardless of their position in the hierarchy and disable it.

I took a look at addHierarchyChangeListener, but it seems to only detect changes in parents, not in children.

Can someone point me in the right way?

+3
source share
2 answers

You are looking for a ContainerListener . Here Sun demonstration .

+4

, RecursiveContainerListener, , . (RecursiveContainerListener.java). , . , , / handleAdd handleRemove .

, , :

parentComponent.add(new RecursiveContainerListener());

:)

+1

Source: https://habr.com/ru/post/1721460/


All Articles