• 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

setPreferredSize() vs GridBagConstraints.fill ?

 
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all.
In my applets, I found that for my components e.g. JTextField, GridBagConstraints.fill = GridBagConstraints.HORIZONTAL would take precedence over component.setPreferredSize(new Dimension(75,17)). In practice, this renders setPreferredSize spurious in a GridBagLayout.
Is this your understanding on how it works, that one either uses fill or setPreferredSize ?
TIA :-)
 
achana chan
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I've answered my own question on this one.
Better stick with GridBagLayout paramaters, its much simpler that way.
On the other hand, if I use them with setPreferredWidth, I achieve some amazing results in terms of granularity. The flip side is its complexity. It seems to interact with GridBagLayout's allocation of column width.
Has anyone tried something like that?
 
Ranch Hand
Posts: 2120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I have only found setPrerredWidth on TableColumn. Do you mean that one?
 
achana chan
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No, I am using jKomponent.setPreferredWidth(new Dimension(int x, int y)) on JTextFields in a GridBagLayout using only GridBag components such as gridx and gridy.
I am happy with it to the extent that it also allows me to fit 2 components into one "cell" , bound by the same gridx and gridy, like this:
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic