JFrame to fit JPanel, pack method not working
843804Dec 5 2004 — edited Dec 30 2004I'm creating a JFrame with a single JPanel in it containg an image. I set the JPanel size to be the height and width of the image, and then tried using the pack() method on JFrame to make the JFrame fit the image. When I run the program though, the JFrame ends up being at the minimum size. I've checked and made sure that the panel is in fact the size of the image, so setting the panel size is not the problem.
I've been able to hack around this by manually determining the number of pixels are used by the borders in the Windows XP look and feel, and setting the JFrame size as the image size plus the border size, but this just doesn't sit well with me, and will probably give me problems when I run my application on other operating systems.
Any clues on what I need to do? Thanks.