• Post Reply Bookmark Topic Watch Topic
  • New Topic

[SWT]GridData not working as expected

 
Rajagopal Manohar
Ranch Hand
Posts: 183
  • Mark post as helpful
  • send pies
  • 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
 
Scott Duncan
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!