2

I have a Label component which can contain a very long text. Label support wrapping:

Label label = new Label( composite, SWT.WRAP | SWT.LEFT );

So when I decrease the width of the parent Composite - just resize it with mouse - the text is wrapped correctly, but the height of the parent Composite is not changed so some part of my Label get hidden.

enter image description here

I tried to add a resize listener to parent composite:

expandBar.addListener( SWT.Resize, new Listener() {
  public void handleEvent( Event e ) {
    Point p = label.computeSize( SWT.DEFAULT, SWT.DEFAULT ) // compute size of the text
    int h = p.y; // ! THIS value doesn't change 
                      // despite text in label became wrapped
    // now set expandBar current item's height = h;
  }
} );

Is there a way to compute the height of the component with regards to wrapping? If no, are there SWT components/layouts which change its size dynamically if the child is getting wrapped?

1

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.