Java SWT: Difference between redraw, reskin, update and requestLayout (and pack)

Can anybody please explain to me the difference of the methods Control.redraw(), Control.update(), Widget.reskin(), Control.requestLayout() and Control.pack()? Unfortunately the API documentation does not tell so much about the differences.

I guess the following:

Control.requestLayout() means calculating the size and position of a control inside a Composite when its content (like a text in a label or text field) has changed and perhaps its displayed size/position is not anymore appropriate. I think I understand Control.pack(): It is just a part of Control.requestLayout or rather Composite.layout() as only the size of controls will be changed but not the position.

Control.redraw() and Control.update(): It seems to me that both methods just paint the control again and you call them when the operating system does not show it correctly anymore. You call the methods if size and position have not changed. The difference between both methods is that update() repaints the control immediately whereas redraw() can do it after some time.

I don't understand when I need to call Widget.reskin(). It seems to me the same as Control.redraw().


  • redraw requests that the control should be redrawn the next time the event loop runs. Most of the time redraws are managed automatically, calling redraw explicitly is rare - usually if you are writing your own control extending Canvas.

    update requests the control is redrawn immediately - used when drawing things like a "rubber band" tracking a mouse drag.

    reskin is intended for the Eclipse RCP CSS support, it isn't something you would normally call.

    requestLayout just requests that the layout method be called as soon as possible. This may be faster that calling layout directly.

    pack is equivalent to:

    setSize(computeSize(SWT.DEFAULT, SWT.DEFAULT, changed));

    It just sets the control to the computed size.

    The Eclipse SWT site also has lots of example and article.