FORTUNE

          THE WAY TO THE MASTER...
          posts - 49, comments - 18, trackbacks - 0, articles - 1
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          SWT Layout-FillLayout

          Posted on 2006-03-08 17:17 fortune 閱讀(1164) 評論(0)  編輯  收藏 所屬分類: 我的學習筆記

          下圖是SWT中的一些術語說明




          SWT共有4種Layout:FillLayout,RowLayout,GridLayout,FormLayout

          FillLayout
          FillLayout是最簡單的Layout,它將widgets放在單行或單列上,強制使它們具有相同的大小,也就是說每個widget的高度和寬度都和其中最高或最寬的那個widget一樣
          marginHeight (與上下邊框的距離),marginWidth (與左右邊框的距離)(since3.0)


          spacing,指定widgets之間的間隔距離(since3.0)

          public class Snippet172 {
           public static void main (String [] args) {
            Display display = new Display ();
            Shell shell = new Shell (display);
            FillLayout fillLayout = new FillLayout ();
            fillLayout.type = SWT.VERTICAL;
            fillLayout.marginHeight = 20;
            fillLayout.marginWidth = 15;
            fillLayout.spacing = 10;
            shell.setLayout (fillLayout);

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

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

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

            shell.pack ();
            shell.open ();

            while (!shell.isDisposed ()) {
             if (!display.readAndDispatch ())
              display.sleep ();
            }
            display.dispose ();
           }
          }

          參考:http://www.eclipse.org/articles/Understanding%20Layouts/Understanding%20Layouts.htm

          主站蜘蛛池模板: 五华县| 德昌县| 夏津县| 宁陵县| 普格县| 龙泉市| 囊谦县| 连州市| 个旧市| 嘉定区| 曲阜市| 浦东新区| 昌宁县| 商都县| 东乌| 论坛| 英吉沙县| 澜沧| 专栏| 巧家县| 元谋县| 陆川县| 峡江县| 于都县| 武乡县| 平凉市| 陆河县| 林西县| 刚察县| 郧西县| 藁城市| 山东省| 八宿县| 芮城县| 乐平市| 峨眉山市| 荃湾区| 松溪县| 广元市| 南投县| 文安县|