user1108983
user1108983

Reputation:

Java applet drawString not working

Please help, I am building a Java applet, and it wont let me display variables. See, this code works:

        g.drawString("wassup",50,25);

But this code doesn't:

int timerx = 10000;
g.drawString(timerx,50,25);

Upvotes: 0

Views: 2543

Answers (1)

cheeken
cheeken

Reputation: 34675

There are two Graphics.drawString() methods. One accepts a String as a first argument and the other accepts an AttributedCharacterIterator. You are attempting to pass an int as the first argument, but there is no method that matches that signature.

If you want to print the characters "10000", try the following code.

int timerx = 10000;
g.drawString(String.valueOf(timerx),50,25);

Upvotes: 3

Related Questions