我不斷收到一個編譯錯誤在返回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