开发者

GridLayout and GridData in eclipse

What the relation between th开发者_如何学Goe two? Why do you have to provide both?


Layouts are there to give your windows a specific look. A layout controls the position and size of children in a Composite. org.eclipse.swt.layout.GridLayout is just an specific instance of org.eclipse.swt.widgets.Layout, which allows you to layout the child components of a composite in a Grid (row-column) manner.

Each widget controlled by a org.eclipse.swt.layout.GridLayout can have its initial width and height specified by setting its org.eclipse.swt.layout.GridData object.

So, the org.eclipse.swt.layout.GridLayout is basically a blue print which describes the layout of controls on a composite.

Whereas the org.eclipse.swt.layout.Griddata is the attribute of the control, describing its span, indentation, margin etc for each gird(cell). Each component should have a unique Griddata.


In the context of SWT, GridLayout an SWT layout manager (i.e., it controls the layout of the form). GridData is a part of GridLayout and enables you to set layout properties on the SWT components participating in the layout. For instance, you can set the horizontal alignment nature of a List component by setting a GridData via cmpnt.setLayoutData(gd).


GridLayout is the Layout Manager for the controls.

GridData specifies how the controls in each cell of the layout behave while displaying.


GridLayout is one of standard layout managers introduced in java 1.0 15 years ago and belongs to package java.awt. GridData is a SWT extension.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜