简体   繁体   中英

Update same label after setting timer GWT

我想每隔5s更新一次标签,它应该是RootLayoutPanel中的唯一标签。当前每隔5s添加一个新标签,但我希望更新相同的标签。能否建议一个方法。

Use Timer to repeat after 5 sec.

Here is code:

import com.google.gwt.user.client.Timer;

final Label label=new Label("Hello ");
Timer timer=new Timer(){

    @Override
    public void run() {
        label.setText("Hello "+Math.random()*100);
    }

};
timer.scheduleRepeating(5000);
RootPanel.get().add(label);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM