【发布时间】:2014-08-23 02:01:06
【问题描述】:
在 Eclipse 中它给了我一堆语法错误,但我看到代码非常好???第 14、23、27 行有语法错误,但就像我说的,它们对我来说似乎很好? :(
package me.slappy826.Everlost.ttf;
import java.awt.Font;
import java.io.InputStream;
import org.lwjgl.opengl.GL11;
import org.newdawn.slick.*;
public class SlickTTF
{
InputStream fontFile = org.newdawn.slick.util.ResourceLoader.getResourceAsStream("assets/everlost/Ubuntu-LI.ttf");
private static TrueTypeFont font;
private Font awtFont = null;
try
{
awtFont = Font.createFont(Font.TRUETYPE_FONT, fontFile);
awtFont = awtFont.deriveFont(20f);
font = new TrueTypeFont(awtFont, true);
} catch(Exception e) {}
public static void drawString(String s, int i, int j, Color color)
{
font.drawString(i, j, s, color);
}
}
【问题讨论】:
-
第 14、23 和 27 行在哪里?
-
第 14 行是私有字体 awtFont = null; |第 23 行是 public static void drawString(String s, int i, int j, Color color) |第 27 行是最后一行。
-
您应该在方法/构造函数内部或静态块内部声明您的 try/catch 块,如 here 解释的那样。
-
报告错误时,始终将 EXACT 和 COMPLETE 错误消息复制/粘贴到您的问题中。