• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Sergio Campos J.
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mohamed Sanaulla wrote:Midlet- mobile application?



Yes, I'm using a Canvas.
 
Mohamed Sanaulla
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
reply
    Bookmark Topic Watch Topic
  • New Topic