-
Bug
-
Resolution: Unresolved
-
P4
-
None
-
1.2.0
-
generic, x86
-
generic, windows_nt
Name: rm29839 Date: 04/07/98
/*
* This program creates a frame that has a GridBagLayoutManager.
* It creates three rows of buttons:
*
* The first row has one button in it, with a gridwidth of 6.
* The second row has two buttons in it, each with a gridwidth of 3.
* The third row has three buttons in it, each with a gridwidth of 2.
*
* The problem is that the two buttons in the second row do not get
* managed so that they split the row in half. The first button
* in the second row seems to behave as if it had a gridwidth of 2.
* The second button in the second row seems to behave as if it
* had a gridwidth of 4.
*
* I have used the GridBagLayout alot with no problems, but I can't
* seem to see what I am doing wrong in this code, so I assume it
* is a bug. I see the same behavior in the 1.2 Beta 3 as well.
*/
import java.awt.*;
public class GBTest
extends Frame
{
public GBTest()
{
super("Test Frame");
setLayout(new GridBagLayout());
Container panel = this;
Button button;
GridBagConstraints gc;
button = new Button("Button1 Width = 6");
gc = new GridBagConstraints();
gc.gridx = 0;
gc.gridy = 0;
gc.gridwidth = 6;
gc.weightx = 1;
gc.fill = GridBagConstraints.HORIZONTAL;
panel.add(button, gc);
button = new Button("Button2 Width = 3");
gc = new GridBagConstraints();
gc.gridx = 0;
gc.gridy = 1;
gc.gridwidth = 3;
gc.weightx = 1;
gc.fill = GridBagConstraints.HORIZONTAL;
panel.add(button, gc);
button = new Button("Button3 Width = 3");
gc = new GridBagConstraints();
gc.gridx = 3;
gc.gridy = 1;
gc.gridwidth = 3;
gc.weightx = 1;
gc.fill = GridBagConstraints.HORIZONTAL;
panel.add(button, gc);
button = new Button("Button4 Width = 2");
gc = new GridBagConstraints();
gc.gridx = 0;
gc.gridy = 2;
gc.gridwidth = 2;
gc.weightx = 1;
gc.fill = GridBagConstraints.HORIZONTAL;
panel.add(button, gc);
button = new Button("Button5 Width = 2");
gc = new GridBagConstraints();
gc.gridx = 2;
gc.gridy = 2;
gc.gridwidth = 2;
gc.weightx = 1;
gc.fill = GridBagConstraints.HORIZONTAL;
panel.add(button, gc);
button = new Button("Button6 Width = 2");
gc = new GridBagConstraints();
gc.gridx = 4;
gc.gridy = 2;
gc.gridwidth = 2;
gc.weightx = 1;
gc.fill = GridBagConstraints.HORIZONTAL;
panel.add(button, gc);
}
public static void main(String args[])
{
GBTest frame = new GBTest();
frame.pack();
frame.show();
}
}
(Review ID: 27195)
======================================================================
/*
* This program creates a frame that has a GridBagLayoutManager.
* It creates three rows of buttons:
*
* The first row has one button in it, with a gridwidth of 6.
* The second row has two buttons in it, each with a gridwidth of 3.
* The third row has three buttons in it, each with a gridwidth of 2.
*
* The problem is that the two buttons in the second row do not get
* managed so that they split the row in half. The first button
* in the second row seems to behave as if it had a gridwidth of 2.
* The second button in the second row seems to behave as if it
* had a gridwidth of 4.
*
* I have used the GridBagLayout alot with no problems, but I can't
* seem to see what I am doing wrong in this code, so I assume it
* is a bug. I see the same behavior in the 1.2 Beta 3 as well.
*/
import java.awt.*;
public class GBTest
extends Frame
{
public GBTest()
{
super("Test Frame");
setLayout(new GridBagLayout());
Container panel = this;
Button button;
GridBagConstraints gc;
button = new Button("Button1 Width = 6");
gc = new GridBagConstraints();
gc.gridx = 0;
gc.gridy = 0;
gc.gridwidth = 6;
gc.weightx = 1;
gc.fill = GridBagConstraints.HORIZONTAL;
panel.add(button, gc);
button = new Button("Button2 Width = 3");
gc = new GridBagConstraints();
gc.gridx = 0;
gc.gridy = 1;
gc.gridwidth = 3;
gc.weightx = 1;
gc.fill = GridBagConstraints.HORIZONTAL;
panel.add(button, gc);
button = new Button("Button3 Width = 3");
gc = new GridBagConstraints();
gc.gridx = 3;
gc.gridy = 1;
gc.gridwidth = 3;
gc.weightx = 1;
gc.fill = GridBagConstraints.HORIZONTAL;
panel.add(button, gc);
button = new Button("Button4 Width = 2");
gc = new GridBagConstraints();
gc.gridx = 0;
gc.gridy = 2;
gc.gridwidth = 2;
gc.weightx = 1;
gc.fill = GridBagConstraints.HORIZONTAL;
panel.add(button, gc);
button = new Button("Button5 Width = 2");
gc = new GridBagConstraints();
gc.gridx = 2;
gc.gridy = 2;
gc.gridwidth = 2;
gc.weightx = 1;
gc.fill = GridBagConstraints.HORIZONTAL;
panel.add(button, gc);
button = new Button("Button6 Width = 2");
gc = new GridBagConstraints();
gc.gridx = 4;
gc.gridy = 2;
gc.gridwidth = 2;
gc.weightx = 1;
gc.fill = GridBagConstraints.HORIZONTAL;
panel.add(button, gc);
}
public static void main(String args[])
{
GBTest frame = new GBTest();
frame.pack();
frame.show();
}
}
(Review ID: 27195)
======================================================================