Originally posted by Jonathan Sternberg:
I am running Windows, and have run the program using both Eclipse and the NetBeans IDE.
If pack is the problem, why does every single tutorial on the site tell me to call pack? If they're calling pack, how are they getting their window to look specifically like it does? Also, for future reference, is there any way for Java to get the monitor resolution? I want to make the program compatible for any resolution, but higher resolutions will have the objects as smaller than they would appear on my computer. Lower resolutions may have the object too big.
pack() isn't a problem, per se. It just causes the frame to reduce to it's preferred size. If you jam in a bunch of components, including a table, some labels, textfields, combo boxes, etc using a layout manager, you'll find that pack() will do its best to respect the preferred sizes of all the components in the frame. The fact is that a JLabel containing "Hello World!" doesn't occupy much space, and it's minimum, preferred, and maximum sizes are pretty well set.
Try commenting out pack() and see what happens!
Resolution causing components to appear smaller or larger is a natural effect of changing resolutions... What is your main concern? Most people don't run resolutions lower than 1024x768 by this point, and I think that's a reasonable amount of space to work with and ensure a visual layout that can scale reasonably well.