日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

java swt gridlayout_SWT界面布局介绍之GridLayout

發布時間:2024/3/26 编程问答 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java swt gridlayout_SWT界面布局介绍之GridLayout 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

GridLayout網格布局時最常用的布局之一,類似于Html中使用table布局。通過使用GridData來設置布局參數。

做個例子看看。

代碼:

import?org.eclipse.swt.SWT;

import?org.eclipse.swt.layout.FillLayout;

import?org.eclipse.swt.layout.GridData;

import?org.eclipse.swt.layout.GridLayout;

import?org.eclipse.swt.widgets.Button;

import?org.eclipse.swt.widgets.Composite;

import?org.eclipse.swt.widgets.Display;

import?org.eclipse.swt.widgets.Group;

import?org.eclipse.swt.widgets.Label;

import?org.eclipse.swt.widgets.List;

import?org.eclipse.swt.widgets.Shell;

import?org.eclipse.swt.widgets.Text;

/**

*?SWT?FillLayout布局使用demo?發郵件

*?@author?xwalker

*

*/

public?class?GridLayoutDemo{

private?Shell?shell;

private?Text?toAddrText;

private?Text?topicText;

private?Text?ccText;

private?Text?labelText;

private?Button?sendBtn;

private?Button?timSendBtn;

private?Button?saveBtn;

private?Composite?composite;

private?Group?group;

public?void?open()?{

Display?display?=?Display.getDefault();

createContents();

while?(!shell.isDisposed())?{

if?(!display.readAndDispatch())?{

display.sleep();

}

}

}

/**

*?創建窗口組件

*/

protected?void?createContents(){

shell=new?Shell();

shell.setText("發郵件");

shell.setSize(800,?450);

shell.setLayout(new?GridLayout(5,?false));

Label?toLabel?=?new?Label(shell,?SWT.NONE);

toLabel.setLayoutData(new?GridData(SWT.RIGHT,?SWT.CENTER,?false,?false,?1,?1));

toLabel.setText("收件人");

toAddrText?=?new?Text(shell,?SWT.BORDER);

toAddrText.setLayoutData(new?GridData(SWT.FILL,?SWT.CENTER,?true,?false,?3,?1));

composite?=?new?Composite(shell,?SWT.NONE);

composite.setLayout(new?FillLayout(SWT.HORIZONTAL));

GridData?gd_composite?=?new?GridData(SWT.FILL,?SWT.FILL,?false,?false,?1,?4);

gd_composite.widthHint?=?171;

composite.setLayoutData(gd_composite);

group?=?new?Group(composite,?SWT.NONE);

group.setText("聯系人");

group.setLayout(new?FillLayout(SWT.HORIZONTAL));

List?list?=?new?List(group,?SWT.BORDER);

insertData(list);

Label?topiclabel?=?new?Label(shell,?SWT.NONE);

topiclabel.setLayoutData(new?GridData(SWT.RIGHT,?SWT.CENTER,?false,?false,?1,?1));

topiclabel.setText("主題");

topicText?=?new?Text(shell,?SWT.BORDER);

topicText.setLayoutData(new?GridData(SWT.FILL,?SWT.CENTER,?true,?false,?3,?1));

Label?ccLabel?=?new?Label(shell,?SWT.NONE);

ccLabel.setLayoutData(new?GridData(SWT.RIGHT,?SWT.CENTER,?false,?false,?1,?1));

ccLabel.setText("抄送");

ccText?=?new?Text(shell,?SWT.BORDER);

ccText.setLayoutData(new?GridData(SWT.FILL,?SWT.CENTER,?true,?false,?3,?1));

Label?contentLabel?=?new?Label(shell,?SWT.NONE);

contentLabel.setLayoutData(new?GridData(SWT.RIGHT,?SWT.CENTER,?false,?false,?1,?1));

contentLabel.setText("內容");

labelText?=?new?Text(shell,?SWT.BORDER);

GridData?gd_labelText?=?new?GridData(SWT.FILL,?SWT.FILL,?true,?false,?3,?1);

gd_labelText.heightHint?=?232;

labelText.setLayoutData(gd_labelText);

new?Label(shell,?SWT.NONE);

sendBtn?=?new?Button(shell,?SWT.NONE);

sendBtn.setText("發送");

timSendBtn?=?new?Button(shell,?SWT.NONE);

timSendBtn.setText("定時發送");

saveBtn?=?new?Button(shell,?SWT.NONE);

saveBtn.setText("存草稿");

new?Label(shell,?SWT.NONE);

shell.open();

}

private?void?insertData(List?list)?{

for(int?i=1;i<=20;i++){

list.add("聯系人"+i);

}

}

public?static?void?main(String[]?args)?{

GridLayoutDemo?demo=new?GridLayoutDemo();

demo.open();

}

}

總結

以上是生活随笔為你收集整理的java swt gridlayout_SWT界面布局介绍之GridLayout的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。