If you examine the executing GridLayoutExample, you discover several problems with the default GridLayout settings. First, the widgets are given a default size, which leads to alignment problems if there are widgets of differing types (as with Label and Text widgets). Second, you see that resizing the window does not result in resizing the widgets, which is one of the basic reasons for using a layout in the first place. The use of additional GridLayout settings and another class called GridData helps solve these issues.
GridData is the class that provides GridLayout with the ability to handle size and position of widgets. Each widget can have a data layout associated with it using the widget's setDataLayout() method. To accomplish this, you must create an instance of the GridData class, then call setLayoutData() on the widget which you are adding to the grid: