aspose file tools*
The moose likes Applets and the fly likes Homework Question (Not looking for someone to do it for me!!) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Homework Question (Not looking for someone to do it for me!!)" Watch "Homework Question (Not looking for someone to do it for me!!)" New topic
Author

Homework Question (Not looking for someone to do it for me!!)

Rebekah McKenna
Greenhorn

Joined: Mar 20, 2008
Posts: 2
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 ]
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Welcome to JavaRanch!

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
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30764
    
156

Rebekah,
We have a separate forum for Applets. I'm going to move your thread there. Not everyone knows about Applets, but the people in that forum know it well!


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Rebekah McKenna
Greenhorn

Joined: Mar 20, 2008
Posts: 2
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!!
 
wood burning stoves
 
subject: Homework Question (Not looking for someone to do it for me!!)