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?

Dzmitry Bahdanovich
  • 1,735
  • 2
  • 17
  • 34
  • To workaround this issue we can use ScrollableComposite as a parent comtainer. See this reference: http://stackoverflow.com/questions/35123/prevent-swt-scrolledcomposite-from-eating-part-of-its-children – Dzmitry Bahdanovich May 08 '14 at 13:43

0 Answers0