Setting the font every game loop is what you should be doing !
Obviously, you don’t want to be recreating the Font object every repaint, so simply create it once from the factory method, and store it.
final Font SYSTEM_PLAIN_SMALL = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_PLAIN, Font.SIZE_SMALL);
public void paint(Graphics g)
{
g.setFont(SYSTEM_PLAIN_SMALL);
renderMenu();
....
}
However, as I highlighted in my previous post, relying on the factory methods to obtain your Font objects can be unwise, it potencially makes you code a little more awkward to port to phones that have buggy Font factory methods (many of them do).
Incidentally, your example contains the method renderMenu(), yet I don’t see any parameters passed to it.
A correctly structured program would have a renderMenu() with a signature more like :-
renderMenu(Graphics g, String [] menuOptions, int selectedIndex)
ofcourse, you could abstract further, having a MenuItem [], or even further, delegating the menu rendering to a Menu class, etc etc.
However, for most J2ME games, the simple suggestion above should suffice.