Forums Register Login

Is there a restriction about where to use repaint() ?

+Pie Number of slices to send: Send
Is there a restriction about where to use repaint()

I mean, should it be called only from inside Keypressed method
or I can use it from a method of my own?

I have a midlet in which repaint() seems to work only inside Keypressed method.
But I'm trying to control all the program flow from a method called Main.

Thanks for any help...
+Pie Number of slices to send: Send
repaint() method has to be called by using the corresponding JPanel/which ever class which provides that method. or from within the class which overrides the class having repaint() method.

Sergio CamposJ wrote: I have a midlet in which repaint() seems to work only inside Keypressed method.



Midlet- mobile application?
+Pie Number of slices to send: Send
 

Mohamed Sanaulla wrote:Midlet- mobile application?



Yes, I'm using a Canvas.
+Pie Number of slices to send: Send
 

Sergio CamposJ wrote:

Mohamed Sanaulla wrote:Midlet- mobile application?



Yes, I'm using a Canvas.



I dont know how it behaves in a Canvas. May be this is related to Java ME?
+Pie Number of slices to send: Send
It is, so I'll move it to our Java ME forum.

In Swing / AWT, there are only two restrictions on calling repaint():
1) do it from the Event Dispatcher Thread.
2) make sure you don't get into an infinite repaint loop (e.g. by calling repaint while you're already painting).
Right! We're on it! Let's get to work tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1063 times.
Similar Threads
repaint () not getting called inside Canvas
Applet wont respond to keyboard input
about GameCanvas
How to refresh JPanel automatically when internal state changed?
How to control the flow of my program?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 18, 2024 20:21:19.