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

          Feedback

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

          主站蜘蛛池模板: 布尔津县| 大邑县| 桃源县| 青海省| 哈巴河县| 溧水县| 科技| 福建省| 浪卡子县| 青海省| 遵化市| 游戏| 武乡县| 莱州市| 电白县| 辰溪县| 南充市| 南安市| 两当县| 通榆县| 邛崃市| 曲阜市| 桑植县| 开阳县| 都昌县| 赤城县| 都匀市| 将乐县| 安康市| 昌乐县| 皮山县| 博兴县| 仁怀市| 遵化市| 寿宁县| 常山县| 恩施市| 天门市| 平武县| 随州市| 巴东县|