• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 9. SWT Layouts > Controlling Widget Sizing and Alignment

9.11. Controlling Widget Sizing and Alignment

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.

9.11.1. How do I do that?

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:


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint