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

GridLayout  RSS feed

 
selvas kumars
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi folks,
If the containers layout is gridbag layout, the component added goes to the center..How to make it to be in topleft position.I tried setting ,gridx=0,
gridy=0,fill=GridBagConstraints.NORTHWEST
nothing is happening, the component is in the center without any change
Any idea on this how to bring to topleft??
Regards,
silva.
 
Vinod Venugopal
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to set weightx=1.0 in constraints. The weightx instance variable of GridBagConstraints is used to determine how to distribute space, which is important for specifying resizing behavior. Unless you specify a weight for at least one component in a row (weightx) and column (weighty), all the components clump together in the center of their container. This is because when the weight is zero (the default), the GridBagLayout object puts any extra space between its grid of cells and the edges of the container.
So thatsy even though u do anything with fill etc, it sticks to the center.

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