I've been trying to figure this out for a while now. Normally I just keep trying until I make it work. The assignment is: Create a JApplet with a JButton that displays my name in blue the first time it is clicked. The second time it is clicked my name should disappear and then print again in bigger dark gray font. This is what I have:
And my button does....ABSOLUTELY NOTHING when I push it. I've been all over the map. First when I ran the applet it showed my button and my name in blue and if I pushed the button my name went away. Then it stopped displaying anything but the button. Can anyone tell me what in the bejebers I'm doing wrong? Maybe I've been staring at this too long!!
Edit by mw: Added Code Tags. [ March 20, 2008: Message edited by: marc weber ]
I don't have much experience with applets, but I noticed a few things...
You're missing a semicolon after the first line in the paint method.
Your "else if" block is indented to suggest that the 4 lines after it should execute with the "if" condition, but there are no braces here, so only the first line is executing as part of the "if." The other 3 will always execute whenever the method is invoked. I think that's causing a problem for you.
After setting the color to white, don't you want to draw the String again?
(Note: I tested this using an Applet viewer, and the position of 250, 250 was out of range. After changing this to 50, 50, the String displayed.)
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
Hey guys! Thanks for all the help. I've fixed a couple of things and I think my code is finally working! I was so close...and to find my errors were small things I overlooked...frustrating!!! Thanks again! I'll try to post in the correct forum next time!!
subject: Homework Question (Not looking for someone to do it for me!!)