Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

GridBagLayout positioning

 
Jose Campana
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hiya Folks !

I'm having trouble figuring out how to place some components using GridBagLayout inside a panel. By using GridBagConstraints and its gridwidth and gridheight properties I was able to get the number of columns I wanted (just one), now I'd like to ask you guys if you know a way to place my components near the top-left corner.

Here are the important bits of my code, I've removed the NetBeans-generated code



I'm attaching two files for your better understanding. The first one(Before.jpg) shows what I've got so far, and After.jpg shows what I want to accomplish. Really easy (I guess), and I need the GridBagConstraints to make it. All Components should be placed in Left-Justified manner, like sticking to the imaginary red vertical line I drew on it.

Ok, That'd be it, I hope you can show me how to do it.

Thanks in advance, and best regards,

Jose
After.jpg
[Thumbnail for After.jpg]
This is What I want But with some Vertical Spacing between CheckBoxes, and I need them all to be LEFT-justified.
Before.jpg
[Thumbnail for Before.jpg]
This is How it Looks now
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
read up on GridBagConstraints' weightx and weighty
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Jose Campana
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Guys, especially Craig.

That is what I was looking for. I started tweaking a lot of other ways before you posted your response and I ended up abandoning GridBag. I used no layout whatsoever... however, I tested your code, and I'll keep it as my backup just in case.

Thanks for the free lesson, I kind of like Swing.

Good Luck,

Jose.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!