Forums Register Login

problem in layout a form.

+Pie Number of slices to send: Send
hello i have created a form layout using grid bag layout..
with four columns and few rows.
but i need to add three combo boxes in second column (for date month and year), but they are overlapping to each other.
here is my code..


i am giving the gridx=1 to all the combo boxes therefore the are overlapping to each other, but i want all in the same column.
how can i do??
i highlight the code for combo boxes..
+Pie Number of slices to send: Send
gridbaglayout is so complex that we almost always need to see a working example of the problem i.e. compilable/runnable

so what's supposed to be at line 257?
+Pie Number of slices to send: Send
actually from line 257, i tried to format the code and tried to change the color, but unfortunately html formatting is not working inside code tags, i think.


this is the code for combo boxes.
all are coming in second column but overlapping each other.
+Pie Number of slices to send: Send
they're all set the same gridx/gridy, so they'd have to overlap
+Pie Number of slices to send: Send
yes, and i make all the gridx of combo like:
gridx=1;
gridx=2;
gridx=3;
now my all the component are shift..
i want all three combos in the second column.
like in second column of all rows text fields are in front of label, but int this row i want three combos of date of birth, in place of text field only.
+Pie Number of slices to send: Send
what is your understanding of gridx and gridy
+Pie Number of slices to send: Send
gridx: number of rows.
gridy: number of columns.
+Pie Number of slices to send: Send
that's gridWidth and gridHeight.

if you want things in a column,
gridx is the same for each, gridy changes
+Pie Number of slices to send: Send
but if i change gridy, they all come in different different rows.
offcourse in same column(because i have not changed the gridx), but i change grid y so rows are changed.
+Pie Number of slices to send: Send
like i did:
+Pie Number of slices to send: Send
I honestly now have no idea what you're trying to do, or want.

from your 1st post
" but i need to add three combo boxes in second column (for date month and year), but they are overlapping to each other. "

then in your 3rd post
"i want all three combos in the second column. "

then in your 5th post
"but if i change gridy, they all come in different different rows. "

so, you want them in a column, original problem - they're overlapping,
now, if they all come in different rows - that's a problem?

perhaps it's time to fire up MS Paint and draw a picture of exactly whta you want and where it is to go,
because all of the above makes no sense to me i.e. in a column, not in different rows and not overlapping
+Pie Number of slices to send: Send
i want like this..
the last are combo boxes, i want in this fashion.
formimg.PNG
[Thumbnail for formimg.PNG]
+Pie Number of slices to send: Send
okay i solved it....
here is what i did..


Thank you for your help...
+Pie Number of slices to send: Send
I just want to help clarify something for you. In GridBagLayout there really isn't any upper limit on the number of columns and rows you have. The layout manager creates them on an as needed basis. What the gridx and gridy mean is not how many there are, but their relative position. So gridx = 0 means that you're putting something all the way to the left, gridy = 0 means you're starting at the top. Now if you increment y, you'll go down another row. If you increment x it'll take you over a column. The more you increment them, the more the layout manager allocates on the panel/frame/whatever. This is where your fill comes in, you can then fill components to take up all available space(GridBagConstraints.BOTH), fill only horizontal(GridBagContraints.HORIZONTAL), or fill only vertical(GridBagContraints.VERTICAL), none which means that it will compact the item as small as it can(GridBagContraints.NONE). You can also specify that an object takes up more than one space with gridheight and gridwidth.
I am going down to the lab. Do NOT let anyone in. Not even this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1807 times.
Similar Threads
problem in GridBagConstraints.fill
Applet sizing problem
Applet doesn't show up with IE
Creating and opening a window if the button is clicked in an applet
Panel appears only when resizing JFrame.
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 13:44:54.