Sorry if I am bringing an old
thread back to life inappropriately, but I am currently have the same problem.
I have a swing application using GridBagLayout. It doesn't look pretty, but it gets the job done. However, I can't get anything centered or looking right no matter what I do.
Here is the code for the item adding and GridBag constraints:
I know I could just do constraints beforehand and add as normal, but it seems to get the job done anyway so I left it. However, this is clearly not doing the trick... now, if I change it around, it still does nothing. Here is a picture of my program:
If there is any more information needed, I'd be happy to provide... I've been at this for hours now trying to make it all look right and I just can't. Any tips? Can't I just say, "Hey, I want the column to be this big, NO BIGGER, and button, I want you to fill up that column, even if the text overlaps." Isn't there ANY WAY to work this around so I can get a static look for my program rather than having to see what it does at runtime? I heard I shouldn't use setPreferredSize(), so I don't plan to, but it seems like my columns are just picking whatever sizes they should and I don't get how to effectively position everything to make it look... well, good.
Thanks guys.