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

Reply
Contributor
Posts: 36
Registered: ‎02-16-2010
My Device: Blackberry Bold
My Carrier: INWI
Accepted Solution

Update Screen

Hi

i want to know how to repaint my screen on blackberry, i used doPaint but it doesn't work for me

is there any function like repaint() in J2ME ?

thks Smiley Very Happy

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Update Screen

It is unusual to have to repaint your screen directly.  Ratter than answering your question, can you explain the situation that you have that makes you think that repainting is required.  I suspect it would be better to look for a more usual way to update your screen.

Contributor
Posts: 36
Registered: ‎02-16-2010
My Device: Blackberry Bold
My Carrier: INWI

Re: Update Screen

hi

thank you for reply

this is the situation :

i have a screen where i paint a message to inform users about the stat  of calling some methods

 

i'm calling 3 functions that gets response from a server and do this on a thread, so at every call i need to print a different message ("getting data : method1" after that "getting data : method 2" etc ...), i don't want to use TextField i'm using paint(Graphics g) .

 

please help me finding a solution

thks  

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Update Screen

painting in this situation is definitely the wrong thing to do.  If you could paint from your network processing then you would be running your network processing on the Event Thread and that is not allowed.

 

Have a look at this code as an example of the more usual way to achieve what you are trying to do:

http://supportforums.blackberry.com/t5/Java-Development/Sample-Please-Wait-or-Progress-Bar-Code/m-p/...

Contributor
Posts: 36
Registered: ‎02-16-2010
My Device: Blackberry Bold
My Carrier: INWI

Re: Update Screen

thaks a lot for the link it's very usefull i will need it to set a progress indicator

 

for now i found this code and it works for me Smiley Happy

 

public void repaint()

{

synchronized (UiApplication.getEventLock())

{

Graphics g = getGraphics();

g.pushRegion(new XYRect(0,0,getWidth(),getHeight()));

this.paint(g);

g.popContext();

}

}

 

 

when i want to do an update to my screen i just call repaint() and it works fine

 

thank you for ur support

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Update Screen

Interesting approach!  I presume this is a method in your Screen (MainScreen) class?

 

You have got over the the Event Thread issue using the eventLock.

 

Looking at this code, it will just repaint the current Screen.  How to do you upate it?

Contributor
Posts: 36
Registered: ‎02-16-2010
My Device: Blackberry Bold
My Carrier: INWI

Re: Update Screen


peter_strange wrote:

Interesting approach!  I presume this is a method in your Screen (MainScreen) class?


yes it's a method to add to the MainScreen

 


peter_strange wrote:

 

Looking at this code, it will just repaint the current Screen.  How to do you upate it?


when i call this method my screen invoke its paint and in such time i'm passing different messages to print that's it, so when i want to update my screen (text in the screen) i just call repaint and it does the work

 

thks Smiley Happy