Are there any easy ways to calculate a component's new bounds?
I'm looking for a way to calculate the new bounds of a component after manually changing its min,max or preferred sizes - but I need the new bounds before the component is painted to them. Adding a ComponentListener and catching the component on resize won't work because the component will already be painted int its new position by the time componentResized is invoked on the ComponentListener.
By adding a PropertyChangeListener, I can get hold of the new preferred size dimensions, this doesn't help in all cases however, since not all layout managers use preferred sizes the same way.
A simple solution would simply be to override paintComponent and catch the bounds before calling super.paintCompont - this requires subclassing, however, and is messy in any circumstance, but especially mine as I am developing a container and don't necessarily know in advance which components will be added to it.
Any comments are appreciated,