Button btn = new Button(parent, SWT.NONE); GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); btn.setLayoutData(gd);
Label lbl = new Label(parent, SWT.NONE); GridData gd = new GridData(SWT.CENTER, SWT.TOP, false, false); lbl.setLayoutData(gd);In example 1, the widget (a Button) will fill the entire cell both horizontally and vertically because the `GridData` constructor specifies `SWT.FILL` for both the horizontal and vertical grab and fill arguments. The `true` arguments tell the layout manager to allocate extra space to this widget if available. In example 2, the widget (a Label) will be centered horizontally and aligned to the top of its cell because `SWT.CENTER` is specified for the horizontal alignment and `SWT.TOP` for the vertical alignment. The `false` arguments indicate that the widget should not grab any extra space in either direction. Package library: org.eclipse.swt.layout is part of the Eclipse Standard Widget Toolkit (SWT) library.