I am trying to create a custom component that animates. But it looks like the animate() method of my component is only called once (instead of beeing called at each EDT cycle) and I don't understand why.
Here are the relevant methods of my custom component:
```
/**
* {@inheritDoc}
*/
public void initComponent() {
if(infinite) {
System.out.println("Animate");
getComponentForm().registerAnimatedInternal(this);
}
}
/**
* {@inheritDoc}
*/
public void deinitialize() {
if(infinite) {
Form f = getComponentForm();
if(f != null) {
System.out.println("UnAnimate");
f.deregisterAnimatedInternal(this);
}
}
}
/**
* {@inheritDoc}
*/
public boolean animate() {
System.out.println("Anim called");
if(infinite) {
float f = (infiniteSpeed * (reverseDirection?(-1):(1)) * ((float)maxValue));
if(((int)f) == 0) {
if(f < 0) {
f = -1;
} else {
f = 1;
}
}
value += ((int)f);
if(value >= maxValue) {
if (reverseAtEnd) {
value = maxValue;
reverseDirection = true;
}
else {
value = (int)0;
}
}
if(value <= 0) {
if (reverseAtEnd) {
value = (int)0;
reverseDirection = false;
}
else {
value = maxValue;
}
}
System.out.println("New value: "+value);
super.animate();
return true;
}
return super.animate();
}
public void setInfinite(boolean i) {
if(infinite != i) {
infinite = i;
if(isInitialized()) {
if(i) {
System.out.println("Animate");
getComponentForm().registerAnimatedInternal(this);
} else {
System.out.println("UnAnimate");
getComponentForm().deregisterAnimatedInternal(this);
}
}
else {
System.out.println("Not initialized");
}
}
}
```
and the output I have in my console with the simulator:
```
Animate
paintComponentBackground finished
Anim called
New value: 3
paintComponentBackground finished
```
As you can see the animate() function is called (so my component seems correctly registered as animated at the parent level). But after that, nothing. The animate() function is not called anymore and my value variable do not change....
I looked at the animated ClockDemo and it looks like pretty similar so I don't understand what is wrong with my code...