aspose file tools*
The moose likes Java Micro Edition and the fly likes Is there a restriction about where to use repaint() ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Is there a restriction about where to use repaint() ?" Watch "Is there a restriction about where to use repaint() ?" New topic
Author

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

Sergio Campos J.
Ranch Hand

Joined: Jun 01, 2009
Posts: 53
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...


"There are times when the easy things should be quick and easy" [...] "and worry about the theory later" -Fred Hamilton-
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3056
    
  33

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?


Mohamed Sanaulla | My Blog
Sergio Campos J.
Ranch Hand

Joined: Jun 01, 2009
Posts: 53
Mohamed Sanaulla wrote:Midlet- mobile application?


Yes, I'm using a Canvas.
Mohamed Sanaulla
Saloon Keeper

Joined: Sep 08, 2007
Posts: 3056
    
  33

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?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19552
    
  16

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).


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is there a restriction about where to use repaint() ?
 
Similar Threads
Applet wont respond to keyboard input
about GameCanvas
repaint () not getting called inside Canvas
How to control the flow of my program?
How to refresh JPanel automatically when internal state changed?