Hi,
I’m trying to display a small animation on the screen and I’m having trouble to synchronize the paint with the drawing on board.
My first attempt was to wait with a Thread sleep:
while (true) {
main.repaint();
main.update();
Thread.sleep(100);
}
All was working fine. Then I try to remove the sleep and then I notice that my animation was missing some images.
If my understanding is correct this is because the draw is actually asynchronous.
But how can I do a wait until draw is done from my Displayable object ?
I tried to add in my paint function:
this.display.waitForEvent();
But instead of synchronization I get the following exception:
Exception in thread “DISPLpmp” java.lang.RuntimeException: MicroUI:E=1
at java.lang.System.getStackTrace(Unknown Source)
at java.lang.Throwable.fillInStackTrace(Throwable.java:82)
at java.lang.Throwable.(Throwable.java:37)
at java.lang.Exception.(Exception.java:18)
at java.lang.RuntimeException.(RuntimeException.java:18)
at ej.microui.display.Display.waitForEvent(Display.java:392)
at com.mycompany.Main.paint(Main.java:152)
at ej.microui.display.Displayable.paintDisplayable(Displayable.java:199)
at ej.microui.display.Display.executeEventRepaint(Display.java:539)
at ej.microui.display.DisplayPump.execute(DisplayPump.java:193)
at com.is2t.microui.io.DisplayPumpKF.internalPump(DisplayPumpKF.java:94)
at ej.microui.display.DisplayPump.run(DisplayPump.java:97)
at java.lang.Thread.run(Thread.java:303)
at java.lang.Thread.runWrapper(Thread.java:454)
Can you help me please ?