[英]Java applet drawString not working
Please help, I am building a Java applet, and it wont let me display variables. 请帮助,我正在构建一个Java applet,它不会让我显示变量。 See, this code works:
看到,此代码有效:
g.drawString("wassup",50,25);
But this code doesn't: 但是这段代码没有:
int timerx = 10000;
g.drawString(timerx,50,25);
There are two Graphics.drawString()
methods. 有两个
Graphics.drawString()
方法。 One accepts a String
as a first argument and the other accepts an AttributedCharacterIterator
. 一个接受
String
作为第一个参数,另一个接受AttributedCharacterIterator
。 You are attempting to pass an int
as the first argument, but there is no method that matches that signature. 您试图将
int
作为第一个参数,但是没有与该签名匹配的方法。
If you want to print the characters "10000"
, try the following code. 如果要打印字符
"10000"
,请尝试以下代码。
int timerx = 10000;
g.drawString(String.valueOf(timerx),50,25);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.