欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

 更新時(shí)間:2009年06月25日 11:14:55   作者:  
相對(duì)于FillLayout來(lái)說(shuō),RowLayout比較靈活,功能也比較強(qiáng)。用戶可以設(shè)置布局中子元素的大小、邊距、換行及間距等屬性。

RowLayout布局 

相對(duì)于FillLayout來(lái)說(shuō),RowLayout比較靈活,功能也比較強(qiáng)。用戶可以設(shè)置布局中子元素的大小、邊距、換行及間距等屬性。

RowLayout的風(fēng)格

RowLayout中可以以相關(guān)的屬性設(shè)定布局的風(fēng)格,用戶可以通過(guò)“RowLayout.屬性”的方式設(shè)置RowLayout的布局風(fēng)格,RowLayout中常用的屬性如下。
Wrap:表示子組件是否可以換行(true為可換行)。
Pack:表示子組件是否為保持原有大小(true為保持原有大?。?。
Justify:表示子組件是否根據(jù)父組件信息做調(diào)整。
MarginLeft:表示當(dāng)前組件距離父組件左邊距的像素點(diǎn)個(gè)數(shù)。
MarginTop:表示當(dāng)前組件距離父組件上邊距的像素點(diǎn)個(gè)數(shù)。
MarginRight:表示當(dāng)前組件距離父組件右邊距的像素點(diǎn)個(gè)數(shù)。
MarginBottom:表示當(dāng)前組件距離父組件下邊距的像素點(diǎn)個(gè)數(shù)。
Spacing:表示子組件之間的間距像素點(diǎn)個(gè)數(shù)。

另外,RowLayout可以通過(guò)RowData設(shè)置每個(gè)子組件的大小,例如“button.setLayoutData (new RowData(60, 60))”將設(shè)置button的大小為(60,60)。
測(cè)試代碼:

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

package swt_jface.demo2;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.RowData;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Shell;
public class RowLayoutSample {

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

RowLayout rowLayout = new RowLayout();
// rowLayout.fill = true;
// rowLayout.justify = true;
// rowLayout.pack = false;
// rowLayout.type = SWT.VERTICAL;
// rowLayout.wrap = false;
shell.setLayout(rowLayout);

Button button1 = new Button(shell, SWT.PUSH);
button1.setText("button1");
button1.setLayoutData(new RowData(100, 35));

List list = new List(shell, SWT.BORDER);
list.add("item 1");
list.add("item 2");
list.add("item 3");

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

//shell.setSize(120, 120);
shell.pack();
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
public static void main(String[] args) {
new RowLayoutSample();
}
}

再看看下面這個(gè)動(dòng)態(tài)的(結(jié)合Composite)
復(fù)制代碼 代碼如下:

package swt_jface.demo2;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class Layouting {
Display display = new Display();
Shell shell = new Shell(display);
int count = 0;
public Layouting() {
shell.setLayout(new RowLayout());

final Composite composite = new Composite(shell, SWT.BORDER);
composite.setLayout(new RowLayout());
composite.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
composite.addControlListener(new ControlListener() {
public void controlMoved(ControlEvent e) {
}
public void controlResized(ControlEvent e) {
System.out.println("Composite resize.");
}
});

Button buttonAdd = new Button(shell, SWT.PUSH);
buttonAdd.setText("Add new button");
buttonAdd.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
Button button = new Button(composite, SWT.PUSH);
button.setText("Button #" + (count++));
composite.layout(true);
composite.pack();
shell.layout(true);
shell.pack(true);
}
});

shell.pack();
//shell.setSize(450, 100);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
display.dispose();
}
public static void main(String[] args) {
new Layouting();
}
}

相關(guān)文章

  • Java emoji持久化mysql過(guò)程詳解

    Java emoji持久化mysql過(guò)程詳解

    這篇文章主要介紹了Java emoji持久化mysql過(guò)程詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2019-07-07
  • SpringCache 分布式緩存的實(shí)現(xiàn)方法(規(guī)避redis解鎖的問(wèn)題)

    SpringCache 分布式緩存的實(shí)現(xiàn)方法(規(guī)避redis解鎖的問(wèn)題)

    這篇文章主要介紹了SpringCache 分布式緩存的實(shí)現(xiàn)方法(規(guī)避redis解鎖的問(wèn)題),本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-11-11
  • Mybatis的一級(jí)緩存和二級(jí)緩存原理分析與使用

    Mybatis的一級(jí)緩存和二級(jí)緩存原理分析與使用

    mybatis-plus 是一個(gè) Mybatis 的增強(qiáng)工具,在 Mybatis 的基礎(chǔ)上只做增強(qiáng)不做改變,為簡(jiǎn)化開發(fā)、提高效率而生,這篇文章帶你了解Mybatis的一級(jí)和二級(jí)緩存
    2021-11-11
  • Java單線程ThreadLocal串值問(wèn)題解決方案

    Java單線程ThreadLocal串值問(wèn)題解決方案

    這篇文章主要介紹了Java單線程ThreadLocal串值問(wèn)題解決方案,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-04-04
  • Java多線程之線程安全問(wèn)題詳解

    Java多線程之線程安全問(wèn)題詳解

    這篇文章主要為大家詳細(xì)介紹了Java多線程之線程安全問(wèn)題,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下,希望能夠給你帶來(lái)幫助
    2022-03-03
  • Mybatis 一對(duì)多和多對(duì)一關(guān)聯(lián)查詢問(wèn)題

    Mybatis 一對(duì)多和多對(duì)一關(guān)聯(lián)查詢問(wèn)題

    這篇文章主要介紹了Mybatis 一對(duì)多和多對(duì)一關(guān)聯(lián)查詢問(wèn)題,需要的朋友可以參考下
    2017-04-04
  • java-制表符\t的使用說(shuō)明

    java-制表符\t的使用說(shuō)明

    這篇文章主要介紹了java-制表符\t的使用說(shuō)明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2021-02-02
  • mybatis定義sql語(yǔ)句標(biāo)簽之delete標(biāo)簽解析

    mybatis定義sql語(yǔ)句標(biāo)簽之delete標(biāo)簽解析

    這篇文章主要介紹了mybatis定義sql語(yǔ)句標(biāo)簽之delete標(biāo)簽解析,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-03-03
  • 基于mybatis中數(shù)組傳遞注意事項(xiàng)

    基于mybatis中數(shù)組傳遞注意事項(xiàng)

    這篇文章主要介紹了mybatis中數(shù)組傳遞注意事項(xiàng),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-09-09
  • Java?web實(shí)現(xiàn)頭像上傳以及讀取顯示

    Java?web實(shí)現(xiàn)頭像上傳以及讀取顯示

    這篇文章主要為大家詳細(xì)介紹了Java?web實(shí)現(xiàn)頭像上傳以及讀取顯示,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-06-06

最新評(píng)論