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
Ideally you'd set the width in the layout you are using. Also, when creating the Label you can set whether you want the contents to wrap or not (i.e. expand vertically).
So here's some examples depending on the layout:
FormLayout:
// Add | SWT.WRAP to get label to wrap
Label testLabel = new Label (parent, SWT.LEFT);
FormData fd = new FormData();
fd.width = 50;
testLabel.setLayoutData (fd);
GridLayout:
// Add | SWT.WRAP to get label to wrap
Label testLabel = new Label (parent, SWT.LEFT);
GridData gd = new GridData ();
gd.widthHint = 50;
testLabel.setLayoutData (gd);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With