林海學苑

          java學習交流

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            12 隨筆 :: 0 文章 :: 1 評論 :: 0 Trackbacks
          因工作上的要求,要將sql運行后得結果集顯示到表格中去,在網上很難找到有類似的代碼。
          以前做的,都是固定的列,用如下代碼即可:
                  table = new Table(composite, SWT.BORDER);
                  table.setLinesVisible(
          true);
                  table.setHeaderVisible(
          true);
                  table.setBounds(
          102836799);

                  
          final TableColumn Column_1 = new TableColumn(table, SWT.NONE);
                  Column_1.setWidth(
          120);
                  Column_1.setText(
          "名稱");

                  
          final TableColumn Column_2 = new TableColumn(table, SWT.NONE);
                  Column_2.setWidth(
          100);
                  Column_2.setText(
          "別名");

          但因為生成的列是不可以刪除的,再加就會有更多的列,感覺沒有辦法了,但其實還有有辦法的。象通過如下方式:

                  TableLayout tLayout = new TableLayout();
                  table.setLayout(tLayout);

                  String[] columns 
          = new String[] "列1""列2""列3" };

                  
          for (int i = 0; i < columns.length; i++{
                      tLayout.addColumnData(
          new ColumnWeightData(100)); // 100個單位的寬度
                      new TableColumn(table, SWT.NONE).setText(columns[i]);
                  }
          posted on 2008-04-29 21:42 林海 閱讀(440) 評論(0)  編輯  收藏 所屬分類: eclipse (插件)

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          主站蜘蛛池模板: 德兴市| 鹤壁市| 湘乡市| 乐亭县| 洛浦县| 辉县市| 丹寨县| 印江| 九江县| 中宁县| 阿克苏市| 类乌齐县| 葫芦岛市| 惠安县| 利川市| 崇左市| 温泉县| 个旧市| 昌都县| 普格县| 阳谷县| 南通市| 吴桥县| 新龙县| 洪湖市| 西盟| 武冈市| 汉沽区| 阳信县| 八宿县| 永吉县| 洞口县| 吉木乃县| 双牌县| 舟曲县| 靖宇县| 上饶市| 长泰县| 徐闻县| 师宗县| 洛隆县|