aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes GridBagLayout HELP 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 HELP" Watch "GridBagLayout HELP" New topic
Author

GridBagLayout HELP

Gregory Thomas
Greenhorn

Joined: Jun 01, 2004
Posts: 11
I am a newbie to the GridBagLayout and in its grid.

My results when I run my test program are:

--------------------------------------------------
Label 1 | textfield | elipse button | Label 2 |
--------------------------------------------------
run button |
--------------------------------------------------

but in actual, I want my results to look like this:

--------------------------------------------------
Label 1 | textfield | elipse button |
--------------------------------------------------
Label 2 |
--------------------------------------------------
run button |
--------------------------------------------------

Here is my code:



Thanks to everyone's help.

Gregory
[ September 29, 2004: Message edited by: Gregory Thomas ]
Terry McKee
Ranch Hand

Joined: Sep 29, 2000
Posts: 173
A couple of things... First, when adding your components to your main window you need to also add the GridBagConstraints object as a second argument. So instead of ...getContentPane().add(btn) you would have ...getContentPane().add(btn, gbc) where gbc is your GridBagConstraints object. Second, it looks like your gridy argument for the last component is wrong. Instead of 3 it should be 2.
Gregory Thomas
Greenhorn

Joined: Jun 01, 2004
Posts: 11
Thank you. Thank you. Thank you. It works. I could stop pulling my eyes out, punching my monitor and cursing.
 
 
subject: GridBagLayout HELP