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

首頁 > 學院 > 開發設計 > 正文

Eclipse Form設計指南之定制布局

2019-11-18 15:40:51
字體:
來源:轉載
供稿:網友

  3、定制布局

  Eclipse Form提供了2個新的布局

 ?。?)TableWrapLayout

  ·問題:假如將上例中超鏈接的文本設置的足夠長

link.setText("This is an example of a form that is mUCh longer and will need to wrap.");
  即使設置了SWT.WRAP,文本內容不會自動WRAP,這是因為體內容的布局是GridLayout

  ·Eclipse Form提供替代的布局TableWrapLayout:類似于GridLayout,但是具有象Html表格一樣自動WRAP功能

  ·下面是解決超鏈接文本自動WRAP的例子:

public void createPartControl(Composite parent) {
 toolkit = new FormToolkit(parent.getDisplay());
 form = toolkit.createScrolledForm(parent);
 form.setText("Hello, Eclipse Forms");

 Composite body = form.getBody();
 TableWrapLayout layout = new TableWrapLayout();
 body.setLayout(layout);
 Hyperlink link = toolkit.createHyperlink(body, "Click here.", SWT.WRAP);
 link.addHyperlinkListener(new HyperlinkAdapter() {
  public void linkActivated(HyperlinkEvent e) {
   System.out.  }
 });

 layout.numColumns = 2;
 link.setText("This is an example of a form that is much longer and will need to wrap.");
 TableWrapData td = new TableWrapData();
 td.colspan = 2;
 link.setLayoutData(td);
 Label label = toolkit.createLabel(body, "Text field label:");
 Text text = toolkit.createText(body, "");
 td = new TableWrapData(TableWrapData.FILL_GRAB);
 text.setLayoutData(td);
 text.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
 Button button = toolkit.createButton(body,"An example of a checkbox in a form", SWT.CHECK);
 td = new TableWrapData();
 td.colspan = 2;
 button.setLayoutData(td);
 toolkit.paintBordersFor(body);
}
  ·下面是程序變化的地方:

  1) TableWrapLayout替代GridLayout

  2) 使用TableWrapData來提供布局數據信息

  3) 設置的屬性使用colspan、rowspan等來源于HTML表格單元的屬性

  ·要注重的是:需要自動WRAP的控件,需要設置成SWT.WRAP風格

 ?。?)ColumnLayout

  ·ColumnLayout是Eclipse Form提供的另一個定制布局

  ·ColumnLayout的布局方式是從上到下,從左到右

  ·在變化Form的寬度時,會自動調整控件列數以適應Form的寬度

  ·ColumnLayout的設置很簡單,通常只要設置列數的范圍(缺省是1-3)

  ·在后面的相關部分會給出使用的例子

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 隆安县| 陆良县| 酒泉市| 搜索| 汕头市| 岑巩县| 三原县| 白水县| 巴中市| 东方市| 新乡市| 响水县| 长白| 衡阳市| 海林市| 海原县| 青田县| 临泽县| 磴口县| 德阳市| 内黄县| 红安县| 西贡区| 洪泽县| 双城市| 庆安县| 石城县| 修武县| 英德市| 宜州市| 麻江县| 确山县| 百色市| 黔江区| 鄯善县| 长乐市| 白水县| 盐城市| 保靖县| 松潘县| 萨迦县|