The component may no have a size until it has been made visible.
Add some debug println statements to print out its size at various locations in the code to see when it has a valid size.