国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Java > 正文

SWT(JFace)體驗(yàn)之FillLayout布局

2020-01-31 16:51:43
字體:
供稿:網(wǎng)友
FillLayout布局

FillLayout是非常簡單的一種布局方式,它會(huì)以同樣大小對父組件中的子組件進(jìn)行布局,這些子組件將以一行或一列的形式排列。一般來說,用戶可以在任務(wù)欄、工具欄中放置FillLayout布局,通過FillLayout布局對子組件進(jìn)行定位,也可以當(dāng)子組件只有一個(gè)組件時(shí),通過FillLayout布局填充整個(gè)父組件的空間。

FillLayout的風(fēng)格

FillLayout布局中,可以把子組件按水平或垂直的方式進(jìn)行排列,這些風(fēng)格是當(dāng)創(chuàng)建FillLayout實(shí)類時(shí)以參數(shù)形式指定的。

演示代碼:
復(fù)制代碼 代碼如下:

package swt_jface.demo2;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class FillLayoutSample {

Display display = new Display();
Shell shell = new Shell(display);
public FillLayoutSample() {

FillLayout fillLayout = new FillLayout(SWT.VERTICAL);
fillLayout.marginHeight = 5;
fillLayout.marginWidth = 5;
fillLayout.spacing = 1;

shell.setLayout(fillLayout);

Button button1 = new Button(shell, SWT.PUSH);
button1.setText("button1");

Button button2 = new Button(shell, SWT.PUSH);
button2.setText("button number 2");

Button button3 = new Button(shell, SWT.PUSH);
button3.setText("3");
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}

public static void main(String[] args) {
new FillLayoutSample();
}
}

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 北辰区| 婺源县| 环江| 托克托县| 东至县| 湟中县| 石阡县| 汝州市| 吐鲁番市| 锡林郭勒盟| 改则县| 松江区| 龙里县| 泰兴市| 灵石县| 龙泉市| 原平市| 扎鲁特旗| 城固县| 化州市| 盐池县| 扶风县| 平泉县| 公安县| 堆龙德庆县| 靖宇县| 措勤县| 大理市| 永德县| 自治县| 临西县| 将乐县| 麻城市| 吉安市| 宜兴市| 昂仁县| 芮城县| 工布江达县| 朝阳县| 桃江县| 宁津县|