Why not calling resized()?

Hi all,

this tutorial says

The Component::resized() function is called automatically whenever anything happens that leads to a size change of the component. Never call this function yourself!

Why? This is a public function. I have built several GUIs with Components calling resized() or `getParentComponent()->resized() in the past and never had any issues with that.

And I could use setBounds()or setSize() and that would call resized() anyway

So did I missed something? Or is it safe to use it?


There is no reason not to call resized(). If you do your layout of child components in resized, then its a common pattern to call resized after adding or removing a child component.

The header file (at least in version 6.x) does not say anywhere that you should not call resized(). There are no side-effects of calling that function, and the default implementation does nothing at all, so there’s really no reason you should not be able to call that if you need to re-arrange your child components or something. Perhaps that documentation is just outdated?

Great, thanks!