2016-10-29 132 views
0

我想讓動畫在1000毫秒內將按鈕從nX,nY移動到n1X,n1Y。GWT:移動微件動畫

我的類: 公共類開始擴展動畫實現入口點{

AbsolutePanel panel = new AbsolutePanel(); 
Label label; 
Button b; 
int a; 

@Override 
protected void onUpdate(double progress) { 

    panel.setWidgetPosition(b, 2*2, 2*2); 
    a++; 
} 

public void onModuleLoad() { 
    panel = new AbsolutePanel(); 
    b = new Button("Click!"); 
    label.setText("111"); 

    RootPanel.get().add(label); 
    RootPanel.get().add(panel); 

     } 

}

回答

0

在GWT製作的動畫是很容易的:

Timer r1 = new Timer() { 
       int num = 100; 
       @Override 
       public void run() { 
        widget.setStyleName("after"); 
} 
      }; 

Timer r = new Timer() { 
       int num = 100; 

       @Override 
       public void run() { 

        widget.setStyleName("before"); 
        num += 10; 
       } 
      }; 

r.scheduleRepeating(1000); 
r1.scheduleRepeating(2000);`