• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem in layout a form.

 
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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..
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
they're all set the same gridx/gridy, so they'd have to overlap
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is your understanding of gridx and gridy
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
gridx: number of rows.
gridy: number of columns.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
that's gridWidth and gridHeight.

if you want things in a column,
gridx is the same for each, gridy changes
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
like i did:
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i want like this..
the last are combo boxes, i want in this fashion.
formimg.PNG
[Thumbnail for formimg.PNG]
 
Punit Jain
Ranch Hand
Posts: 1143
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
okay i solved it....
here is what i did..


Thank you for your help...
 
Ranch Hand
Posts: 39
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 think he's gonna try to grab my monkey. Do we have a monkey outfit for this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic