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 單飛 閱讀(961) 評論(1)  編輯  收藏 所屬分類: Eclipse Plugin

          Feedback

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

          主站蜘蛛池模板: 沧源| 钟祥市| 乌审旗| 聂拉木县| 资兴市| 饶平县| 邢台市| 阿巴嘎旗| 县级市| 陇南市| 通许县| 神木县| 康乐县| 东丽区| 浑源县| 南汇区| 深州市| 沂水县| 东阿县| 闻喜县| 扎囊县| 太康县| 秦皇岛市| 玛多县| 萨迦县| 济宁市| 壶关县| 平果县| 上饶县| 吐鲁番市| 永顺县| 武邑县| 黑河市| 砚山县| 定襄县| 安远县| 阳东县| 阜康市| 新竹市| 延庆县| 广灵县|