I have broken one long line because it made the code hard to read.
I can never seem to get pack() to work myself. Maybe somebody will explain it; maybe you need to set a preferred size on each child component before pack() works.
If you are using grid bag, I suggest you comment out as many of the add instructions as you can. Get it down to one component only. Then compile and run the code. Then reinstate the second component (etc etc). Also, I suggest you get rid of grid bag constraints and use
Horstmann's GBC class instead. If you can, find the description of GBC in Horstmann‘s Core
Java II book (Vol
I).
Another simpler solution (which I should have noticed earlier
) might be to move the setVisible() call to where it belongs. Only set anything visible
after adding all its components. So setVisible should be the last line in the constructor/setUpGUI method.