• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

GridBagLayout HELP

 
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 ]
 
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!