Click here to Skip to main content
14,385,111 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hi i want to set a label size to fix size.
and not change the label size acceding to it's text
how can I do it please?

Thanks
Posted

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

You have to add LayoutData to the Label.
This Data object is basically consisting of some constrains, telling the label how to look.

Label oLabel = new Label (parent, SWT.NONE);

GridData oGridData = new GridData ();
oGridData.widthHint = 50;
oLabel.setLayoutData (oGridData);


You should think about a generalized implementation if you need it more than once (e.g. to get all labels look the same).
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100