youYou must be careful with setting the size... if you set the size from the JFrame you override the ability of pack().
youYou should ONLY theset the size of the content, not of the JFrame itself.
this pic shows you the difference between content size and JFrame size:
