• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Trouble with paint

 
sam barker
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am having the following problem.

From class1(which extends Canvas) depending on the key pressed,
I change the display and try to change the font colour(in the new display).

The problem is that when the repaint has no effect and only when I exit keyPressed function I see the final colour change for image created by paint for class2

public void keyPressed(int keyCode)
{
if(keyCode == Canvas.KEY_POUND)
{
Display.getDisplay(this).setCurrent(class2_obj);//class2 extends canvas
repaint();//Should call class2 paint()
.....
.....
repaint();//Should call class2 paint()
}
}
 
Darryl Burke
Bartender
Posts: 5149
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
//Should call class2 paint()

Huh? Any unqualified method invokation refers to the intance of the class in which the code resides i.e. repaint() is equivalent to this.repaint(). Not to [some other object].repaint().
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic