• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

GridBagLayout positioning

 
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
read up on GridBagConstraints' weightx and weighty
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
 
Jose Campana
Ranch Hand
Posts: 339
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
What a stench! Central nervous system shutting down. Save yourself tiny ad!
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic