Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Kristof Camelbeke
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here it is with GridBagLayout:
 
Kristof Camelbeke
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the help in this issue !
Kristof
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic