Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4126689
Votes 28
Synopsis GridBagLayout gridwidth parameter is not used properly.
Category java:classes_awt
Reported Against 1.2rc1 , 1.2beta3
Release Fixed
State 3-Accepted, bug
Priority: 4-Low
Related Bugs
Submit Date 07-APR-1998
Description


/*
 * 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)
======================================================================
Work Around
N/A
Evaluation

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


======================================================================
Comments
  
  Include a link with my name & email   

Submitted On 14-OCT-2001
bernie01
Since 1998 (possibly earlier). It's depressing. Simple
"fencepost space allocating algorithm" breaks.

Does Sun want to actively discourage programmers to use Java
on the client?

Yeah, it's not high tech at all.
But when it comes to the latest esoteric addition to the
language, hundreds of messages are exchanged by those who
have the time to promote their egos.

In case of the most basic functions such as this and when
there is absolutely no room for discussion, when things are
trivial to reproduce and fix, then who cares?

I guess and I sincerely hope this has been overlooked
priority-wise somehow. Who is going to ring the alarm bell?


Submitted On 16-OCT-2001
abies
I'm not using GridBagLayout, so I'm not personally involved,
but:
1) Fixing this bug will break many, many applications
2) Maybe correcting GridBugLayout yourself is an option ?
Rename it and correct code.
I know that this is not a 'real' solution, but at least
there is no native code involved here, no tricks with linux
window managers, no gc pauses...
THIS IS A SINGLE JAVA CLASS. If this is an only blocker for
your project, write your own. For me 50MB memory usage and
20s startup time are _serious_ problems, not single bug in
obscure class.


Submitted On 16-OCT-2001
adamc
This absolutely, positively should get fixed asap.


Submitted On 19-OCT-2001
lsayo
I vote for fixing this bug! I need to write java apps
on the client...



PLEASE NOTE: JDK6 is formerly known as Project Mustang