Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Screen.invalidate() does not cause a subsequent call to paint()

by BlackBerry Development Advisor ‎02-16-2010 03:32 PM - edited ‎09-16-2010 02:43 PM (1,924 Views)

Summary

 

This article applies to the following:

  • BlackBerry® smartphones running BlackBerry® Device Software 4.6
  • SDR210700

Details

 

Problem

 

When you call invalidate() from within the paint method of a class that extends the Screen class, the screen is not repainted.

 

Cause

 

When called from the paint method, invalidate() does not add a paint request to the event dispatch queue.

 

Resolution

 

This is a previously reported issue that has been escalated internally to our development team. No resolution time frame is currently available.


Workaround

 

To get the screen to repaint, you can embed a call to invalidate() within a new runnable object and pass that object to the UiApplication.getUiApplication.invokeLater(..) method, as shown in the following example:

 

 

public void paint( Graphics g ) {
   // do drawing

   // use invokeLater(..) to call our invalidate() method
   UiApplication.getUiApplication().invokeLater( new Runnable()
      {
         public void run() {
            invalidate();
         }
      }, 1, false
   );
}

 

Contributors