Occasionally you may need to write your own custom Layout class. This is most appropriate when you have a complex layout that is used in many different places in your application. Note that unless you are writing a very generic layout that will be used by several Composite widgets, it is sometimes simpler and easier to calculate sizes and position children in a resize listener.
Layouts are responsible for implementing two methods:
A third method, flushCache(...), can be optionally implemented to clear any cached data associated with a specific control. Often, the computeSize() method of a widget can be expensive, and so layouts can cache results to improve performance.
Further discussion of custom layouts can be found in Understanding layouts in SWT.