File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes GridBagLayout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "GridBagLayout " Watch "GridBagLayout " New topic


Ken Sampson
Ranch Hand

Joined: Sep 26, 2007
Posts: 45

I am confused as to how to work on GridBagLayout. Below is the sample code that i have tried ..

GBC is a customised class which extends GridBagConstraints and is defined

On running the above code I find that button 5 is covered by button 4 and is not displayed at all. On investigating I find that if I remove mentioning gridwidth and gridheight then button 5 gets displayed.

Please help to understand how to get around this problem.

Ken Sampson
Ilja Preuss

Joined: Jul 11, 2001
Posts: 14112

The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Ted Smyth
Ranch Hand

Joined: May 28, 2008
Posts: 73
Originally posted by Ilja Preuss:

Oh goodness that's golden...!

I haven't used GridBag in a long time, nor do I plan on it.

Not that I'm trying to give plugs to certain developers, but I really think MigLayout ( is a phenomenal LayoutManager, which really eclipses Gridbag in simplicity and flexibility.

Edward Smith
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
I agree. Here's the link:
subject: GridBagLayout
It's not a secret anymore!