The Goal
Keep walking……
posts - 23,  comments - 1,  trackbacks - 0

最常用的一种layout.以row layout为基础。

package com.swtjface.Ch6;
import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
public class Ch6GridLayoutComposite extends Composite {
public Ch6GridLayoutComposite(Composite parent) {
super(parent, SWT.NONE);
GridLayout layout = new GridLayout(4,false);//每一行有4个control,后一个参数是a
boolean to indicate whether the columns should take up an even amount of
space. By passing false, you tell the layout to only use the minimum amount of
space needed for each column.

setLayout(layout);
for (int i = 0; i < 16; ++i) {
Button button = new Button(this, SWT.NONE);
button.setText("Cell " + i);
}
}
}

Using GridData styles
十分类似于RowData对象。可通过其构造函数来设定STYLE,这些STYLE可分为3类:FILL, HORIZONTAL_ALIGN, and VERTICAL_ALIGN.
1.FILL:此cell是否fill所有的availabe的空间。可用的值还包括FILL_HORIZONTAL(水平扩张),FILL_VERTICAL(垂直扩张),FILL_BOTH。
2.ALIGN,用来指定control在cell中的什么位置。值包括BEGINNING, END, CENTER和FILL。
具体参见下表

Using GridData size attributes
与RowData不同,GridData还有很多的public属性。其中有些是布尔值类型的,一般会根据所设置的不同styles而自动管理,所以无需对其直接操作。还有一些是integer值,用来确定单个cells的大小。具体件下表:

posted on 2006-04-11 16:16 JOO 阅读(331) 评论(0)  编辑  收藏 所属分类: SWT & JFace IN ACTION

只有注册用户登录后才能发表评论。


网站导航:
 
Hit the target!

<2006年4月>
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

常用链接

留言簿(2)

随笔分类(23)

随笔档案(22)

文章档案(1)

相册

Neighbor

搜索

  •  

最新评论

阅读排行榜

评论排行榜