The main problem with your code is that the Font object is only in scope for the entire try block, so it is no longer available in your return statement at the end of the method. Two options:
Move the variable declaration outside the try block:
Font menuFont = null; try { menuFont = Font.createFont(...); } catch (...) { } return menuFont;
Or, do return Font.creatFont(...) inside try, thereby avoiding the need for a variable in the first place (and, obviously, return null at the end of the method).
source share