Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Applet repaint newbie help  RSS feed

 
Joe Vaughn
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Greetings. Hopefully this is the right place to ask this question--I searched through the Applets discussion but wasn't sure if it was the right place for a newbie q.
I've been banging my skull against my keyboard on this one. I need a smiley face to change to a frowny face when a Jbutton is clicked. I got the face, the smile, & the frown, but can't get the smile to go away when the button is clicked. I think it has something to do w/repaint, but then again I'm not positive b/c my berloody textbook is pretty vague.
I've included mycode & any comments would be most appreciated.
Thanks Much,
Joe
code to follow:
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch, Joe!
Your question is to do with understanding GUIs. So, I'm moving this to the Swing / JFC / AWT forum, where they just love to talk about that messy stuff. (Get it? GUI == gooey == messy.)
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A couple of suggestions:
1. What would happen if you were keep all of the painting code in the paint method, and just paint different things based on some condition, which could be changed at the press of a button?
2. If you want something that has been painted to disappear, you might want to paint something over it. (Perhaps a line the same color as the background.)
 
Joe Vaughn
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dirk Schreckmann:
A couple of suggestions:
1. What would happen if you were keep all of the painting code in the paint method, and just paint different things based on some condition, which could be changed at the press of a button?

I couldn't quite this to work--still a newbie.
2. If you want something that has been painted to disappear, you might want to paint something over it. (Perhaps a line the same color as the background.)

However, this worked *perfectly*! Thank you so very much as it never occurred to me!
Working Code to Follow:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!