Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "GridBagLayout...!" Watch "GridBagLayout...!" New topic
Author

GridBagLayout...!

Billy Green
Greenhorn

Joined: Dec 30, 2005
Posts: 7
I have some code that i want to display some text field. I am using panels and have textfield and lables positioned using GridBagLayout. When i compile it does not display how i thought it should:

I want it to be like

Name -------------- Surn -------------------

Address ---------------------------------------

Address ---------------------------------------

Country -------------- Post-------------------

but it bunches it all together...please could someone help me get this right?

Thanks,

B

the code is:


Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
Billy Green
Greenhorn

Joined: Dec 30, 2005
Posts: 7
Thanks,

Thats now showing as i would like. Would you be kind enough to tell me where i was going wrong? I see that you have commented out alot of constraints and just want to get a better idea of what i need to do next time.

Thanks,

Bil
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
The gridwidth constraint specifies how many columns you want a component to span/occupy as stated in the gridwidth section in the discussion section of the GridBagLayout api. Check out the code example in the discussion section. Note how the constraints instance is altered along the way.
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
Hey Billy, welcome to JavaRanch. Would you please remove the redundant letters from your name? The ranch naming policy requires normal names so we can keep up the friendly, personal atmosphere. Thanks.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: GridBagLayout...!
 
Similar Threads
arrange the spacing between components
GridBagLayout problem
GridBagLayout problems
help automate code
How to make the window (JPanel?) bigger in gridbaglayout