United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4126689 : GridBagLayout gridwidth parameter is not used properly.

Details
Type:
Bug
Submit Date:
1998-04-07
Status:
Open
Updated Date:
2008-04-16
Project Name:
JDK
Resolved Date:
Component:
client-libs
OS:
windows_nt,generic
Sub-Component:
java.awt
CPU:
x86,generic
Priority:
P4
Resolution:
Unresolved
Affected Versions:
1.2.0
Targeted Versions:

Related Reports

Sub Tasks

Description
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)
======================================================================

                                    

Comments
EVALUATION

Name: dkR10074			Date: 07/20/2001

###@###.### 2001-07-20
  jdk1.3     - the bug is reproducible
  jdk1.3.1   - the bug is reproducible
  jdk1.4-b70 - the bug is reproducible


======================================================================
                                     
2004-09-14



Hardware and Software, Engineered to Work Together