• 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

SWT Text - setSize ignored in GridLayout

 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys,

I am trying to set the width of a Text object to a fixed size (it's a zip code field so there aren't more than 5 characters going in) but for some reason the call to setSize is ignored.

Whats also odd is that when the text field is initialized and empty it has space to take 9 characters. When it is initialized with text it is only wide enough to take the characters. How come ??


Thanks
 
Sheriff
Posts: 22787
131
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Swing most layout managers ignore the size and use the preferred size instead. AWT's GridLayout uses the preferred size of the biggest components, to make sure all fit.

If this doesn't help you, you can still create a panel with a different layout (in AWT a FlowLayout comes to mind). Add the text field to that, then add the panel to the container. This notion of nesting layout managers is very common in Swing.

I hope this story applies to SWT as well.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic