林海學苑

          java學習交流

            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
            12 隨筆 :: 0 文章 :: 1 評論 :: 0 Trackbacks
          因工作上的要求,要將sql運行后得結果集顯示到表格中去,在網(wǎng)上很難找到有類似的代碼。
          以前做的,都是固定的列,用如下代碼即可:
                  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 (插件)

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


          網(wǎng)站導航:
           
          主站蜘蛛池模板: 平顶山市| 南昌市| 贺州市| 汶川县| 望奎县| 普兰店市| 绍兴县| 台北市| 怀远县| 剑川县| 承德市| 余庆县| 翁牛特旗| 恩平市| 得荣县| 阳东县| 西盟| 合阳县| 临汾市| 乌拉特后旗| 上思县| 达拉特旗| 车险| 金湖县| 农安县| 聂拉木县| 绥阳县| 陆丰市| 汪清县| 卢氏县| 应用必备| 乡宁县| 陆良县| 河南省| 湘西| 阜城县| 乐昌市| 太仓市| 河东区| 盐城市| 元阳县|