Question

so in my japanel, I have a componenet which is 2 columns wide. I would like to add 4 buttons at the bottom not exceeding this 2 column. however, what I get is all 4 buttons stretch out across to 4 columns, exceeding two clumns. the cancelButton also has a weird horizontal elongation .

        gbc.gridx = 0;
    gbc.gridy = 0;  
    gbc.gridwidth = 2;
    gbl.setConstraints(someComponenetHere, gbc);                    

    gbc.gridy = 2;  
    gbl.setConstraints(applyButton, gbc);

    gbc.gridx = 1;
    gbc.gridy = 2;  
        gbc.gridwidth = 1;
    gbl.setConstraints(cancelButton, gbc);

    gbc.gridx = 2;
    gbc.gridy = 2;  
    gbc.gridwidth = 1;
    gbl.setConstraints(applyAddButton, gbc);

    gbc.gridx = 3;
    gbc.gridy = 2;  
    gbc.gridwidth = 1;
    gbl.setConstraints(applyAddAllButton, gbc);
Was it helpful?

Solution

My approach would be to make you component 4 columns wide and stick a button in each column.

Failing that you could create a Panel containg 2 buttons and stick one of those panels in each column.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top