This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes GridbagLayout help needed (this time with code tags :-) ) 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 help needed (this time with code tags :-) )" Watch "GridbagLayout help needed (this time with code tags :-) )" New topic
Author

GridbagLayout help needed (this time with code tags :-) )

Kristof Camelbeke
Ranch Hand

Joined: Nov 28, 2001
Posts: 97
I have the following layout : (T= Textfield)


The problem is I want the last Textfield of 2 positions right next to the first TextField... So I want something like this :

Does anybody know what GridBagConstraints I have to use to achieve this. I just can't seem to place the TextFields with 2 positions after the first TextField.... Thanks for any reply...
Kristof
Bob Dobalina
Ranch Hand

Joined: May 24, 2001
Posts: 53
Just so I'm understanding this correctly, you've got a long and then a short text field on the first line, then a single, long text field on each of the next two lines, followed by long and short text fields on the next lines?
To do this, you'd probably be best off creating nested panels. So, the top line with two text fields would be a single panel which could be added to the top row in the GridBag. Then the second and third lines could be added just by adding the longer text field, then new panels added for the remaining rows.
Either that, or create a table with seven rows and two columns, and set the gridwidth to be two for the second and third rows, and gridwidth to be one for the other rows. I think that would work also...
Hope this helps.
-tim
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
Here it is with GridBagLayout:
Kristof Camelbeke
Ranch Hand

Joined: Nov 28, 2001
Posts: 97
Thanks for the help in this issue !
Kristof
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
You're welcome.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: GridbagLayout help needed (this time with code tags :-) )
 
Similar Threads
string index out of range
checkbox list in struts 2
Getting an Average
Markov Model Close to being complete but needs a little help
GridbagLayout help needed