我不断收到一个编译错误在返回menuFont行它说没有变量menuFont。有人可以告诉如何解决这个问题。尝试捕获内存访问变量
import java.awt.Font;
import java.awt.FontFormatException;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class loadFiles {
Font getFont(){
try {
Font menuFont = Font.createFont(Font.TRUETYPE_FONT, new FileInputStream("font.ttf"));
} catch (FileNotFoundException e) {
System.out.println("Cant find file.");
e.printStackTrace();
} catch (FontFormatException e) {
System.out.println("Wrong file type.");
e.printStackTrace();
} catch (IOException e) {
System.out.println("Unknown error.");
e.printStackTrace();
}
return menuFont;
}
}
非常感谢你。 – twilding 2012-03-04 00:22:27