SWT(JFace)體驗之FillLayout布局
更新時間:2009年06月25日 11:11:07 作者:
FillLayout是非常簡單的一種布局方式,它會以同樣大小對父組件中的子組件進(jìn)行布局,這些子組件將以一行或一列的形式排列。
FillLayout布局
FillLayout是非常簡單的一種布局方式,它會以同樣大小對父組件中的子組件進(jìn)行布局,這些子組件將以一行或一列的形式排列。一般來說,用戶可以在任務(wù)欄、工具欄中放置FillLayout布局,通過FillLayout布局對子組件進(jìn)行定位,也可以當(dāng)子組件只有一個組件時,通過FillLayout布局填充整個父組件的空間。
FillLayout的風(fēng)格
FillLayout布局中,可以把子組件按水平或垂直的方式進(jìn)行排列,這些風(fēng)格是當(dāng)創(chuàng)建FillLayout實類時以參數(shù)形式指定的。
演示代碼:
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();
}
}
FillLayout是非常簡單的一種布局方式,它會以同樣大小對父組件中的子組件進(jìn)行布局,這些子組件將以一行或一列的形式排列。一般來說,用戶可以在任務(wù)欄、工具欄中放置FillLayout布局,通過FillLayout布局對子組件進(jìn)行定位,也可以當(dāng)子組件只有一個組件時,通過FillLayout布局填充整個父組件的空間。
FillLayout的風(fēng)格
FillLayout布局中,可以把子組件按水平或垂直的方式進(jìn)行排列,這些風(fēng)格是當(dāng)創(chuàng)建FillLayout實類時以參數(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();
}
}
相關(guān)文章
解決spring-boot2.0.6中webflux無法獲得請求IP的問題
這幾天在用 spring-boot 2 的 webflux 重構(gòu)一個工程,寫到了一個需要獲得客戶端請求 IP 的地方,在寫的過程中遇到很多問題,下面小編通過一段代碼給大家介紹解決spring-boot2.0.6中webflux無法獲得請求IP的問題,感興趣的朋友跟隨小編一起看看吧2018-10-10
SpringBoot 項目中的圖片處理策略之本地存儲與路徑映射
在SpringBoot項目中,靜態(tài)資源存放在static目錄下,使得前端可以通過URL來訪問這些資源,我們就需要將文件系統(tǒng)的文件路徑與URL建立一個映射關(guān)系,把文件系統(tǒng)中的文件當(dāng)成我們的靜態(tài)資源即可,本文給大家介紹SpringBoot本地存儲與路徑映射的相關(guān)知識,感興趣的朋友一起看看吧2023-12-12
詳解微信開發(fā)之a(chǎn)ccess_token之坑
access_token分類一是普通access_token,二是網(wǎng)頁授權(quán)access_token。這篇文章主要介紹了詳解微信開發(fā)之a(chǎn)ccess_token之坑,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-10-10
java多線程之wait(),notify(),notifyAll()的詳解分析
本篇文章是對java多線程 wait(),notify(),notifyAll()進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06

