0
我試圖通過的Java奇怪的錯誤時,試圖加載圖像
public static void main(String[] args) {
Arcanus arc = new Arcanus();
try {
terrain = ImageIO.read(getClass().getResource("Arcanus Terrain Tileset.png"));
Font customFont = Font.createFont(Font.TRUETYPE_FONT, new File("Golden-Sun.ttf")).deriveFont(12f);
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
ge.registerFont(Font.createFont(Font.TRUETYPE_FONT, new File("Golden-Sun.ttf")));
arc.setFont(customFont);
} catch (IOException e) {
e.printStackTrace();
} catch (FontFormatException e) {
e.printStackTrace();
}
}
加載使用
static Image terrain = null;
隨後的圖像,但我得到以下錯誤
Uncompilable source code - non-static method getClass() cannot be referenced from a static context
我有不知道爲什麼它做這個任何幫助將是一個驚喜
你可以請張貼更多的來源? – BoppreH
是的錯編輯它 – Mark9135
更改'getClass()'到'YourClassNameHere.class' – DirkyJerky