9910

          單飛

             :: 首頁 :: 聯系 :: 聚合  :: 管理
          private Label doneLabel;
          private Timer timer;

              public class ATask extends TimerTask {
                  @Override
                  public void run() {
                      showScrollText(doneLabel);
                     

                  }
              }

              /**
               * 滾動顯示字幕
               *
               * @param toDoLabel
               */
              private void showScrollText(final Label toDoLabel) {
                  if (toDoLabel != null) {
                      if (toDoLabel.isDisposed()) {
                          timer.cancel();
                          return;
                      }
                      shell.getDisplay().asyncExec(new Runnable() {
                          // @Override
                          public void run() {
                              String txt = toDoLabel.getText();
                              if (txt != null && txt.length() > 50) {
                                  txt = txt.substring(1, txt.length())
                                          + txt.substring(0, 1);
                                  toDoLabel.setText(txt);
                              }
                          }

                      });

                  }
              }
          構造的時候
          // 滾動顯示字幕
                  timer = new Timer();
                  timer.schedule(new ATask(), 0, 500);

                  //
              }

              // @Override
              public void dispose() {
                  timer.cancel();
                  super.dispose();
              }
          private Timer timer;

              public class ATask extends TimerTask {
                  @Override
                  public void run() {
                      showScrollText(doneLabel);
                     

                  }
              }


              /**
               * 滾動顯示字幕
               *
               * @param toDoLabel
               */
              private void showScrollText(final Label toDoLabel) {
                  if (toDoLabel != null) {
                      if (toDoLabel.isDisposed()) {
                          timer.cancel();
                          return;
                      }
                      shell.getDisplay().asyncExec(new Runnable() {
                          // @Override
                          public void run() {
                              String txt = toDoLabel.getText();
                              if (txt != null && txt.length() > 50) {
                                  txt = txt.substring(1, txt.length())
                                          + txt.substring(0, 1);
                                  toDoLabel.setText(txt);
                              }
                          }

                      });

                  }
              }


          構造的時候
          // 滾動顯示字幕
                  timer = new Timer();
                  timer.schedule(new ATask(), 0, 500);

          // @Override
              public void dispose() {
                  timer.cancel();
                  super.dispose();
              }



          posted on 2010-08-06 16:47 單飛 閱讀(959) 評論(1)  編輯  收藏 所屬分類: Eclipse Plugin

          Feedback

          # re: swt 顯示滾動字幕 2010-10-27 17:29 一意孤行
          exe4j可以把swt打包exe  回復  更多評論
            

          主站蜘蛛池模板: 正蓝旗| 色达县| 常山县| 浦北县| 永和县| 古田县| 驻马店市| 雷波县| 正安县| 灵山县| 嘉兴市| 扎赉特旗| 张掖市| 嘉鱼县| 阿拉善右旗| 大冶市| 宜兰市| 邹城市| 航空| 泰和县| 永寿县| 新沂市| 额敏县| 泗洪县| 平江县| 西峡县| 岳普湖县| 绥中县| 邵阳县| 景东| 康乐县| 新营市| 南通市| 宜章县| 双辽市| 库车县| 射洪县| 商城县| 依安县| 亚东县| 宝丰县|