我可以在Java图形中使用拉链
我正在制作爪哇游戏。我可以绘制图像和其他内容,但是拉链给了我一个错误:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: sun.font.SunFontManager
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at sun.font.FontManagerFactory$1.run(FontManagerFactory.java:82)
at java.security.AccessController.doPrivileged(Native Method)
at sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74)
at java.awt.Font.getFont2D(Font.java:491)
its longer...
这是代码:
Font font = new Font("Arial",50,Font.PLAIN);
g2.setFont(font);
g2.drawString("Hello World!", 100, 100);
g2.dispose();
I am making a Java game. I can draw images and other things, but drawString gives me an error:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: sun.font.SunFontManager
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at sun.font.FontManagerFactory$1.run(FontManagerFactory.java:82)
at java.security.AccessController.doPrivileged(Native Method)
at sun.font.FontManagerFactory.getInstance(FontManagerFactory.java:74)
at java.awt.Font.getFont2D(Font.java:491)
its longer...
This is the code:
Font font = new Font("Arial",50,Font.PLAIN);
g2.setFont(font);
g2.drawString("Hello World!", 100, 100);
g2.dispose();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Oracle有一个有用的教程,创建带有swing 的GUI。使用Netbeans IDE部分跳过学习秋千。
您的一小部分代码在两个地方是错误的。
您的
字体
构造函数采用字符串,font
类型和int点大小。您不处理
PaintComponent
图形
对象。我可以想象您的代码其余部分中还有多少其他错误和误解。
Oracle has a helpful tutorial, Creating a GUI With Swing. Skip the Learning Swing with the NetBeans IDE section.
Your tiny bit of code is wrong in two places.
Your
Font
constructor takes a String,Font
type, and int point size.You don't dispose of a
paintComponent
Graphics
object.I can just imagine how many other errors and misconceptions there are in the rest of your code.