I have a loop adding fields to a manager, I am trying to delay the time between when each field is painted onto the screen. I have been trying below code but it just paints the manager when all fields have been added to it.
Is this possible ?
manager.add(field);
manager.invalidate();//force a repaint of the manager
Thread.sleep(1000);
Thanks
Invalidate doesn’t necessarily force a paint, it simply says that on the next paint the Field (or Manager in your case) needs to be redrawn. It’s a subtle difference but it could be causing the confusion. What you might want to try is calling
Screen.doPaint(), which will force the entire screen to redraw. Also, putting the sleep() in your Event Thread won’t help, because painting is also done on the same Thread.If you are trying to sequentially add Fields to your Manager with this second delay, you should put this logic in its own Thread and do
synchronized(UiApplication.getEventLock()){//add fields}when you call manager.add(field). Then you can call yourThread.sleep(1000)to correctly have the delay in displaying. Also, just as a some added info, callingadd()inherently causes an invalidate() call, so you don’t need to add it. Here’s a simple example of the second delay in addingThe painting should occur after the add(), but if it doesn’t you can also make a call to
yourScreen.doPaint()