aspose file tools*
The moose likes Applets and the fly likes Compiling Errors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Compiling Errors" Watch "Compiling Errors" New topic
Author

Compiling Errors

Sue Hunt
Ranch Hand

Joined: Jan 26, 2004
Posts: 50
Greetings all. Have probably posted this in the wrong place, but the way I'm going, what else is new *grin*.
I am getting the following error when I try to compile a program. I've managed to solve the other errors, but can't seem to get around this one.
..\DiceApplet.java:30: cannot resolve symbol
symbol : method drawString (java.lang.String,int)
location: class java.awt.Graphics2D
g2.drawString("Number of throws = " + (int)numberOfThrows, 30);
numberofThrows is defined in the code as
private int numberofThrows = 1;
also have the
import java.awt.Graphics2D;
in too.
I've tried taking the (int) out from before numberOfThrows but that doesn't seem to make a difference.
Any help would be appreciated. Trying to do this, learn a new content management system, get back on top of ASP and do three uni courses...who signed me up for this....oh yeah, it was me....
Cheers
Sue
[ January 26, 2004: Message edited by: Sue Hunt ]
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8873
    
    8

This error indicates that there is no drawString() method in the Graphics2D class which accepts a String and an int as an argument. Take a look at the documentation and find method which will suit your needs.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Sue Hunt
Ranch Hand

Joined: Jan 26, 2004
Posts: 50
Thanks for your help Joe.
I added, one little number and lo and behold it worked.
Funny how something so obvious, isn't always so straight forward, even when staring you in the face.
[ January 27, 2004: Message edited by: Sue Hunt ]
Douglas Braxton
Ranch Hand

Joined: Jan 28, 2004
Posts: 36
sue
i have had a similar problem and it seems joe pointed you in the right direction. what to learn from this?:
the message
..\DiceApplet.java:30: cannot resolve symbol
symbol : method drawString (java.lang.String,int)
location: class java.awt.Graphics2D
g2.drawString("Number of throws = " + (int)numberOfThrows, 30);
is telling the user the compiler is expecting a certain # of parameters for the invoked method and the number supplied does not match.
funny thing about these error messages is when you know what they mean they start to make sense.
Sue Hunt
Ranch Hand

Joined: Jan 26, 2004
Posts: 50
Thanks for that Douglas.
Yes, once the brain twigs, it does make sense.
I have another assignment to do, and just over a week to do it and don't know where to start...other than Chapter 6 of Big Java.
Have to write a class, which will import some text from a text file and send it to a "cleaner" (already written), which will replace a given word with ****, then send it back and print it out. This is to show that we know how to "test".
Any hints would be appreciated, but definitely not asking anyone to write it, as that wouldn't be ethical.
Cheers
Sue
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8873
    
    8

Originally posted by Sue Hunt:

Any hints would be appreciated, but definitely not asking anyone to write it, as that wouldn't be ethical.

Sounds like someone has been lurking in these forums for a while.
You could start with the Java Tutorial:
IO: Reading and Writing and figuring out how to read text files.
Sue Hunt
Ranch Hand

Joined: Jan 26, 2004
Posts: 50
I haven't been lurking honest.
Just didn't want anyone thinking I was after someone to write it for me...
Just wishing I had more time to spend actually reading java and coming to grips with it, rather than working....hahahaha.
Anyway, Joe, thanks for the point.
Sue
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8873
    
    8

Originally posted by Sue Hunt:
I haven't been lurking honest.

Lurking isn't a bad thing. That's why we have the forum, so we can learn from the experiences of others. I've picked up a ton of stuff from here that I never would have come across in my day job. You asked a good question. You sure aren't coming across like the clown that wrote this thread: help me please,please give the program. not kidding. That's really the topic title.
However, you should probably ask questions that don't deal with applets in the Beginner forum. It's got more traffic than Applets and you'll get faster/better/more answers.
 
 
subject: Compiling Errors