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 Help me with alignment. 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 "Help me with alignment. GridBagLayout" Watch "Help me with alignment. GridBagLayout" New topic

Help me with alignment. GridBagLayout

Lisa Abraham

Joined: Aug 16, 2012
Posts: 4
hi. i want to align heading to the top centre and i want to align rest of my fields and labels to the left after heading. i have tried alot but cant do it.

i want to do it like this

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
> i have tried alot but cant do it.

your post reads (to me) like a 'please fix this', but that's not how this site operates.

you need to (at least) have your posted code display all the components in their unaligned positions,
then we can make suggestions for improvement.
Lisa Abraham

Joined: Aug 16, 2012
Posts: 4
First of all, i would like to set these two in alignment. If i can know how to set these two, then i can do remaning by myself. Please help me with this. that how can i allign these two options that have added.
JLabel and JTextField
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46367
Welcome to the Ranch

Before messing around with grid bag, you should find out about Cai Horstmann’s GBC class, which there is a link to in this post.
Darryl Burke

Joined: May 03, 2008
Posts: 5115

1. Follow standard Java coding conventions. Variable names start with a lowercase letter.

2. Have you gone through the Oracle tutorial on GridBagLayout?

edit 3. Please BeForthrightWhenCrossPostingToOtherSites

luck, db
There are no new questions, but there may be new answers.
I agree. Here's the link:
subject: Help me with alignment. GridBagLayout
It's not a secret anymore!