Java Swing set “actual” Frame size (inside)

I have a JFrame which contains just one JPanel. I have tried setting the Panel's size and packing the frame, but that has no effect.

If I set the JFrame's size, it will change the size so it includes the title bar and borders. How do I set the "actual size" so it doesn't include the title bar and borders?



Thanks in advance, guys


You could set the contentPane's preferredSize and call pack on the JFrame, but in general it's usually best to let components size themselves based on their preferred sizes as determined by their layout managers.