if(the parent container's layoutManager is null)
{
size
}
else
{
preferredSize
}
> Which one can I use?
For what?
The preferred, minimum and maximum sizes are used by the layout manager as suggestions to determine the size of a component based on the rules of the layout manager. The layout manager will then set the size of the component.
When a component is painted, it is always painted at its size.