• Post Reply Bookmark Topic Watch Topic
  • New Topic

Problem with repaint()  RSS feed

 
Felix Chien
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java Noob here.
I'm having trouble with getting my graphics object to repaint a simple rectangle with a updated color.
This is just a simplified version of what I was doing hence the seemingly non related names.



Panel code follows


Button panel follows



Any ideas? I feel like it's something simple I can't seem to focus on.
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The SkylinePanel which you see is the one added to the JFrame in the Background class. The SkylinePanel on which you invoke setIsDay(2) in SkylineButtonPanel is a different instance. So it's not surprising that the color of the rectangle in the first SkylinePanel doesn't change.
 
Rob Spoor
Sheriff
Posts: 21052
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Darryl is right. You should pass the SkylinePanel reference to the SkylineButtonPanel:
 
Felix Chien
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aye, thanks guys I understand what the problem was now.

Again thanks for the replies
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!