fatcodeguy
Programmer
Hi, I'm creating a small dialog using GridBagLayout. I have
one label, one text field and two buttons.. here's my code (they are set in a larger pane, and I want them at the top, that's why anchor north and yweights)
c.insets = new Insets(5,5,5,5);
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.NORTH;
c.gridx=0;
c.gridy=0;
c.weightx=0.0;
c.weighty=0.0;
c.gridwidth=1;
c.gridheight=1;
rightPanel.add(label,c);
c.fill=GridBagConstraints.BOTH;
c.gridx=1;
c.gridy=0;
c.weightx=0.0;
c.weighty=0.0;
c.gridwidth=2;
c.gridheight=1;
rightPanel.add(textField,c);
c.gridx=1;
c.gridy=1;
c.weightx=0.0;
c.weighty=-1;
c.gridwidth=1;
c.gridheight=1;
rightPanel.add(button1,c);
c.gridx=2;
c.gridy=1;
c.weightx=0.0;
c.weighty=-1;
c.gridwidth=1;
c.gridheight=1;
rightPanel.add(button2,c);
My problem is that I want the two buttons under the text field to be exactly the same size. How do I do this?
one label, one text field and two buttons.. here's my code (they are set in a larger pane, and I want them at the top, that's why anchor north and yweights)
c.insets = new Insets(5,5,5,5);
c.fill = GridBagConstraints.NONE;
c.anchor = GridBagConstraints.NORTH;
c.gridx=0;
c.gridy=0;
c.weightx=0.0;
c.weighty=0.0;
c.gridwidth=1;
c.gridheight=1;
rightPanel.add(label,c);
c.fill=GridBagConstraints.BOTH;
c.gridx=1;
c.gridy=0;
c.weightx=0.0;
c.weighty=0.0;
c.gridwidth=2;
c.gridheight=1;
rightPanel.add(textField,c);
c.gridx=1;
c.gridy=1;
c.weightx=0.0;
c.weighty=-1;
c.gridwidth=1;
c.gridheight=1;
rightPanel.add(button1,c);
c.gridx=2;
c.gridy=1;
c.weightx=0.0;
c.weighty=-1;
c.gridwidth=1;
c.gridheight=1;
rightPanel.add(button2,c);
My problem is that I want the two buttons under the text field to be exactly the same size. How do I do this?