• 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]GridData not working as expected

 
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
The GridData.horizontalAlignment is not working as I expected. I am unable to Center my widgets. The following code will demonstrate my problem. Please tell me where I went wrong (This is the first time I am trying out GridLayout as I found FormLayout very tiresome and thought GridLayout will give adequate flexibility with less pain)





When I run the code the label appears to the left of the screen rather than center.
Please help,

Regards,
Rajagopal
 
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure but it looks to me like the label should span the entire width of composite since the composite layout calls for 3 columns and the GridData attached to the label spans all three of those columns as well. Could it be that the composite is not appearing on the shell as you would expect? Try putting a SWT.BORDER to the composite. Maybe that will help you see what is going on....
 
Rajagopal Manohar
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Not sure but it looks to me like the label should span the entire width of composite since the composite layout calls for 3 columns and the GridData attached to the label spans all three of those columns as well.



Exactly I wanted the Label to center the width of the composite at the top.

Try putting a SWT.BORDER to the composite. Maybe that will help you see what is going on....



I did and the composite is positioned as one would expect it to.

Now reluctantly I am forced to go back to FormLayout. Still I dont understand why this is not working some please help...

 
Rajagopal Manohar
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I was able to solve the issue. I only had to add one line of code


I dont know how I managed to miss that even after going through the document
 
reply
    Bookmark Topic Watch Topic
  • New Topic