This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of Darcy DeClute's Scrum Master Certification Guide: The Definitive Resource for Passing the CSM and PSM Exams and have Darcy DeClute on-line!
See this thread for details.
  • 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
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

GridBagLayout:: a few Qs

 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i wonder how one can control one component's display area

i'm playing with this gui and some components show much larger then their preferred or minimum sizes should predict; i even created a JButton customized class were i fixed preferred button size but with no effect

i also tried several combinations of constraints but with no effect.

I would like buttons of first row appear with their minimum or at least heir preferred size: that would make subsequent buttons to display smaller too.

How can i achieve it?

TiA

[ July 02, 2005: Message edited by: miguel lisboa ]
[ July 04, 2005: Message edited by: miguel lisboa ]
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cannot see the sanpshot of your UI.
Can u send the relevant code instead.
 
miguel lisboa
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oops

thanks for pointing that out
actually i'm not at my pc, so as soon as i get there i'll post it
 
miguel lisboa
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i've img correctly posted now, i hope

in case you need, i'll post relevant code

TiA
 
Swati Udas
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes now I can see the snapshot..
I think u have set gridwidth=1; or some such setting for the GridBagConstraints for the Buttons..
If this is not the case..please post the code snippet..
else remove the gridwidth setting.. just dont set it to anything.
 
miguel lisboa
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
that's exactly what i have:

i kept the HORIZONTAL fill because i want the buttons together; if i change to fill = NONE then all buttons float aside but still occupy that whole space... too big too much
 
Swati Udas
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
U can adjust the spacing between buttons by adjusting insets..
moreover the buttons with occupy whole space because u have given anchor=lineEnd.
Try giving EAST/WEST as u want it to be.
Another tip is ..
sometimes using the same gridBagconstraints variable for multiple UI elements can mess up the UI..(as per my experience).. So I prefer to use a new GridBagConstraints variable for each button/UI element.
 
miguel lisboa
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
control buttons width that's what i'll do as soon as i have some time ... and i guess that's all what's left

moreover the buttons with occupy whole space because u have given anchor=lineEnd.
(...)
sometimes using the same gridBagconstraints variable for multiple UI elements can mess up the UI..(as per my experience).. So I prefer to use a new GridBagConstraints variable for each button/UI element.



bingo!

thanks a lot!
[ July 05, 2005: Message edited by: miguel lisboa ]
 
miguel lisboa
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i did it; just in case someone is interested, here's the whole code:




BTW just a curiosity: i typed twice (for both buttons subclasses)
>serialver ClassName
and got the very same serialVersionUID
[ July 05, 2005: Message edited by: miguel lisboa ]
 
Swati Udas
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Great!! can we see a snapshot of your final result now !!
 
miguel lisboa
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


 
Evacuate the building! Here, take this tiny ad with you:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic