Problem using GUI from other classes then Main()

Hi guys,

just started to work with JME3.

at the moment I try to create the GUI in a own class (for making the Main() easier to read).

At this time it`s just a “healthbar”.

I used the HUDText from the patterns to do this.

Now the Problem:

when i do this from the Main() everything works fine. I then toke it to an HUDcontroller called class, istantiated a HUDController and used it`s Method for updating the HUD.

On starting the game it brakes directly and a null-pointer-exception is thrown:

Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
at mygame.HUDcontroller.healthMeter(
at mygame.HUDcontroller.showHUD(
at mygame.Main.updateHUD(
at mygame.Main.simpleUpdate(
at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(
at com.jme3.system.lwjgl.LwjglDisplay.runLoop(

HUDController line 22 is:

guiFont = assetManager.loadFont(“Interface/Fonts/Default.fnt”);

cause its the first line of the exception i think this is the mainpoint of the problem, but i don`t understand why it works from the Main() (its exactly the same line)

is there any way i have to adept this path for the fonts when i dont use it from main?

Thanks for help and greetings from Germany,


Ok, i guess i figured out one part of the Problem, but not enough to fix it:

i thought i needed HUDcontroller to extend SimpleApplication for using the guiNode. Now i read that i never should extend SimpleApplication more then ones(in the Main()) but use the AbstractAppState instead.

reading the AppState chapter in the local help lets me think that this is definetly not the way to go for a simple HUDcontroller.

I now need an idea to use all the thinks the simpleapplication have from an other class.

Pass the stuff you need when you create the object. Simple basic Java stuff, really.