Forums Register Login

GridLayout

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.

When people don’t understand what you are doing they call you crazy. But this tiny ad just doesn't care:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 842 times.
Similar Threads
GridLayout help!
BorderLayout placement Constraint
Layout Problem, Help Me Plz
my brand spanking new layout manager
Centering in a JPanel
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 20:17:27.