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 单飞 阅读(948) 评论(1)  编辑  收藏 所属分类: Eclipse Plugin

Feedback

# re: swt 显示滚动字幕 2010-10-27 17:29 一意孤行
exe4j可以把swt打包exe  回复  更多评论
  


只有注册用户登录后才能发表评论。


网站导航: