Click here to Skip to main content
12,357,409 members (73,157 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: Java
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 13-Nov-12 3:23am
t t312

1 solution

Rate this: bad
 
good
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).
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 13 Nov 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

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