This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Does anyone have ideas why the paint method isn't called at all?  RSS feed

 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've tried to put a breakpoint at repaint(), it does hit,
But down below on the paint method, g.drawImage was never called.
Let me know
Thanks
Jack

 
Campbell Ritchie
Sheriff
Posts: 55333
157
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should by now know not to override the paint method.
 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Modified a bit, it works now, but didn't know what the cause was.
Thanks
Jack

 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:You should by now know not to override the paint method.


Seems like the @Override causing the dilemma
Update:
Seems not, why the paint method shouldn't be overrided?
Should I use a timer instead?
Thanks
Jack
 
Bernhard Goetz
Ranch Hand
Posts: 57
1
Java Netbeans IDE Oracle
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jacky,
check out this Learning Trail from the java tutorials.

Regards,
Bernhard
 
Campbell Ritchie
Sheriff
Posts: 55333
157
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should know to use the paintComponent method.
 
Rob Spoor
Sheriff
Posts: 21048
85
Chrome Eclipse IDE Java Windows
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JWindow doesn't have a paintComponent method (since it extends Window, not JComponent), but that just means that custom painting should be done using a JPanel that's added to the JWindow.
 
Jacky Luk
Ranch Hand
Posts: 634
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys, I have able to use a JPanel inside the JFrame successfully
Thanks for the guidance.
Jack
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!