Re: GridBagLayout not behaving as specified



"Ian Wilson" <scobloke2@xxxxxxxxxxxxx> wrote in message news:46262fa9$0$6950$fa0fcedb@xxxxxxxxxxxxxxxxx

[snip]

After
panel.add(dbButton, gbc);
I added
gbc.gridx = 1;
gbc.gridy = 2;
gbc.gridwidth = 1;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.anchor = GridBagConstraints.EAST;
gbc.weightx = 0.0;
gbc.weighty = 0.0;
gbc.insets = new Insets(0, 4, 18, 8);
gbc.ipadx = 0;
for (int x=0; x < 16; x++) {
gbc.gridx=x;
panel.add(new JLabel(Integer.toString(x)), gbc);
}
The results are interesting.
I think you could use fewer than 16 columns and this might make things more predictable. I suspect some columns are shrinking to zero width because no component STARTS in them.

I have indeed tried fewer columns and the results are identical. I have tried as few as 6 columns which is the minimum required to get the results I desire. It just doesn't seem to work as it should.

Personally I'd use MigLayout and have about 1/10th the code.

I have never used it but I really need to understand why this code is failing. Any other ideas?

--
And loving it,

-Q
_________________________________________________
Qu0llSixFour@xxxxxxxxx
(Replace the "SixFour" with numbers to email me)

.


Quantcast