Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need help in ball breaker game

 
rahul taiwala
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello every body i have some painting problem with the game can anybody help.....
here is the code
Untitled.jpg
[Thumbnail for Untitled.jpg]
problem
 
rahul taiwala
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
use paint method instead of paintComponent and its working fine.....
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
rahul taiwala wrote:use paint method instead of paintComponent and its working fine.....


This solution sounds very wrong. Sorry but it sounds like you're fixing the wrong thing, but I can't say what since I can't get your code to compile or run due to missing classes. One problem I see that is not causing your main question but can bite you later is that you have program logic within your paint/paintComponent method as indicated by my comment // **** here ****:



and program logic should not be in this method as you do not have full control as to when or if it will be called. Also it is strange to see a repaint() call within a paint/paintComponent method. If the JVM weren't smart, this would cause an infinite recursive cycle.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic