Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GridBagLayout HELP

 
Gregory Thomas
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you. Thank you. Thank you. It works. I could stop pulling my eyes out, punching my monitor and cursing.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic