Java小程序drawString不工作

发布于 2024-12-29 06:19:18 字数 203 浏览 1 评论 0 原文

请帮忙,我正在构建一个 Java 小程序,它不允许我显示变量。看,这段代码有效:

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

但是这段代码无效:

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

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);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夜光 2025-01-05 06:19:18

有两个 Graphics.drawString() 方法。一个接受 String 作为第一个参数,另一个接受 AttributedCharacterIterator。您尝试传递 int 作为第一个参数,但没有与该签名匹配的方法。

如果您想打印字符“10000”,请尝试以下代码。

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

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文