Relatively new to Swing coding. I have an applicaiton with many panels, all using grid bags.. (I found it the easiest one to get things into the places i want them to be in). Everything looks nice when there is enough space, but when i crop the window to some very small size, instead of just not being able to see most of the panels, they seem to be attempting to dynamically resize to fit the window, and its all getting bunched up and overlapping jlabels etc, how do I stop this ?
Now, you have to set the constraints properly; that is the hard part of using GridBad. Remember that the gridX means the column number, and gridY means row number; I got those two the wrong way round at first and got no end of confusion.
The weight means how much you allow the size of each component to change as you alter the size of the whole display; the greater the weight, the more it changes. Since weight is demoninated in doubles rather than int, you can have a lot of variation in change.
The fill determines whether or not each component fills up its allotted space; you can get components far to small because you haven't given them a fill value.
The anchor determines which side or corner of the allotted space your component hangs onto; in my example it says NORTH, so the button will hang onto the top of its space.
The Insets determines how much empty space there is; in this case 5 px at left and right, and 10 at top and bottom, between the component and its allocation.
There is also internal padding, which I have never actually used myself, and gridwidth and gridheight which mean how many rows or columns you use for a particular component.
You will probably have to use fill and weight to get your display to behave itself.
Any use to you??? CR
Joined: Oct 13, 2005
Did you get it to work?
Looking back at my post yesterday, I see it is full of spelling mistakes, and I have typed , instead of . Sorry.