• Post Reply Bookmark Topic Watch Topic
  • New Topic

GridBagLayout problems  RSS feed

 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Very frustrating, just when you think you get the hang of this layout, it turns around and does the unexpected...
Here's the code:

My results - in the center of the panel, I see a very small JList, right next to it are two labels superimposed on each other, and right next to that, a text field that can take one character.
I've rebuilt this thing from scratch, drawn it out, etc. I can not for the life of me see where this is going wrong.
Could someone give insight into this, I think I've been staring at it too long and my mind's getting muddled.
Thanks
Jason
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Threw a bunch of weights in there, and after several repeated efforts, finally got it looking like I want.
Thought weights were just for resizing, but nope, they're extremely important.
[ March 08, 2002: Message edited by: jason adam ]
 
Roy Ben Ami
Ranch Hand
Posts: 732
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the documentaion says that in order for the components to work correctly as you want them at least one of them has to have a weightx=1.0 in a row and a weighty=1.0 in height.
if not, they are just all centerd in the middle cause the layout doesnt know how to distribute the size between them.
other than that, it affects how the extra spaced is divided among the components when you resize the container.
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah, read that after posting. Or else you get what I had and everything is all jumbled up in the center.
Don't do a lot of GUI programming, think I need to practice more
Thanks for the tip
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!