Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Reducing margins of between components in GridBagLayout  RSS feed

 
Alex Monari
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm using a gridbaglayout as per a tutorial I'm following to build a specific application.

Using the image below I'm looking to improve the layout of my form by reducing the gaps between the top of my form and my name row

https://drive.google.com/file/d/0B2lBPXKQBuQHakJVMmVwQ1ZueFE/view?usp=sharing

And essentially do the same but with the gap between the name and occupation rows.

The image below is my desired result.

https://drive.google.com/file/d/0B2lBPXKQBuQHQjI3MVQyNG9jQUE/view?usp=sharing

Any ideas regarding how I could go about improving my design.

Here's my GridBalayout code:

 
Rob Camick
Ranch Hand
Posts: 2752
11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would suggest you are using the weighty value incorrectly.

Read the section from the Swing tutorial on How to Use GridBagLayout. You can see from that example the default is to not leave space between components. So you should be able to start with that example and then add some insets to get your desired spacing.

If you need more help then post a proper SSCCE, like you asked to do before.
 
Campbell Ritchie
Sheriff
Posts: 53720
127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also find out about Cay Horstmann's GBC class.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!