you'll find this snippet, which answers your 'centering' question
"GridBagConstraints.weightx, GridBagConstraints.weighty Used to determine how to distribute space, which is important for specifying resizing behavior. Unless you specify a weight for at least one component in a row (weightx) and column (weighty), all the components clump together in the center of their container. This is because when the weight is zero (the default), the GridBagLayout object puts any extra space between its grid of cells and the edges of the container."
Deirdre Hackett
Greenhorn
Joined: Feb 13, 2008
Posts: 5
posted
0
Thanks Michael for that. I included the line gBC.weighty = 1; but i still don't seeem to be getting what I want. It still places the first placed JPanel in the centre (vertically). I would like the first JPanel to appear in the top left hand corner, without there being anything else placed in the panel.
Or perhaps I am using the wrong Layout manager entirely. Any suggestions on what might work better?
Thanks MD for your help but I have now abandoned that approach entirely based on other advice. I am going back to drawing the graphics directly onto a JPanel. Still none the wiser but apparently JPanels aren't the way.