WARNING: Problem during creation of Mouse

Good day,



Using SWING and jME.  I basically have a Canvas composed of a Panel on the left (SWING) and a scene on the right (SimpleCanvasImpl)



I try to pick objects attached to my rootNode.



In the init section, I do:





        InputSystem.createInputSystem("LWJGL");

        input = new InputHandler();



        Mouse mouse =  new AbsoluteMouse("a mouse", width, height);

        input.setMouse( mouse );



        MouseAction pick = new MouseAction(cam, rootNode, mouseText);

        pick.setKey("mousepick");

pick.setMouse(input.getMouse());

input.addAction(pick);



      rootNode.attachChild(mouse);





Under simpleUpdate().



mouse.update();





I get the following in the logs:

7-Oct-2005 11:01:28 AM com.jme.input.lwjgl.LWJGLMouseInput <init>

WARNING: Problem during creation of Mouse.



And then later on:

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

at com.jme.input.AbsoluteMouse.update(Unknown Source)

at com.jme.input.AbsoluteMouse.update(Unknown Source)

at test.MyImplementor.simpleUpdate(MyImplementor.java:242)

at com.jme.util.awt.SimpleCanvasImpl.doUpdate(Unknown Source)

at com.jme.util.awt.lwjgl.LWJGLCanvas.paintGL(Unknown Source)

at org.lwjgl.opengl.AWTGLCanvas.paint(AWTGLCanvas.java:256)

at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)

at sun.awt.RepaintArea.paint(RepaintArea.java:224)

at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:254)

at java.awt.Component.dispatchEventImpl(Component.java:4031)

at java.awt.Component.dispatchEvent(Component.java:3803)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)



I suspect that using InputSystem.createInputSystem("LWJGL"); is creating the problem.  So I switched to:



InputSystem.createInputSystem("JInput");



Instead of Muse creation problem I get this:

WARNING: KeyInput is null, insure that a call to createInputSystem was made before getting the devices.

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

at com.jme.input.AbsoluteMouse.update(Unknown Source)

at com.jme.input.AbsoluteMouse.update(Unknown Source)

at test.MyImplementor.simpleUpdate(MyImplementor.java:243)

at com.jme.util.awt.SimpleCanvasImpl.doUpdate(Unknown Source)

at com.jme.util.awt.lwjgl.LWJGLCanvas.paintGL(Unknown Source)

at org.lwjgl.opengl.AWTGLCanvas.paint(AWTGLCanvas.java:256)

at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)

at sun.awt.RepaintArea.paint(RepaintArea.java:224)

at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:254)

at java.awt.Component.dispatchEventImpl(Component.java:4031)

at java.awt.Component.dispatchEvent(Component.java:3803)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

Addionally if I remove mouse.update() then it does not crash but I get:

7-Oct-2005 11:07:46 AM com.jme.input.InputSystem getKeyInput

WARNING: KeyInput is null, insure that a call to createInputSystem was made before getting the devices.



And of course my object picking still does not work…

The Swing implementation has not been hooked up to the input systems yet.  To get an idea of how you might use the mouse with swing though, see RenParticleEditor.  I will look into this issue more later in .10's development.

ok, will do.  Maybe if you tell me how the hooking up should be done I could help…



Also, I have a problem with displaying text.  No text is displayed I get only a yellow blur line.



      mouseText = new Text("Mouse Text Label", "Testing Mouse");

        mouseText.setRenderState(getFont());

        mouseText.setRenderState(as1);

        mouseText.setLocalTranslation(new Vector3f(1, 40, 0));



        rootNode.attachChild(mouseText);



public void simpleUpdate() {     



        mouseText.print("FPS");

}




private TextureState getFont() {

        TextureState font = getRenderer().createTextureState();

        font.setTexture(TextureManager.loadTexture(SimpleGame.class

                .getClassLoader().getResource(fontLocation), Texture.MM_LINEAR,

                Texture.FM_LINEAR));

        font.setEnabled(true);

        return font;

    }




Any ideas?



I noticed that RenParticleEditor does not have text either in the jme canvas.  Is that a bug also?

RenParticleEditor doesn't use text at all, that's way there isn't Text displayed.  :slight_smile:



Your code looks fine.  I added it locally to the RenParticleEditor.MyImplementor subclass and specified fontLocation = "com/jme/app/defaultfont.tga"; and it shows up just dandy.  I'd double check that your font graphic is in your path where you think.

Thanks for the help.



For RenParticleEditor, the FPS is displayed in the console.  Most jME examples it is displayed in the scenegraph… So I thought that maybe there was a link.



But no it still does not work… i tried to use the same fontLocation as you and my test uses tje jme.jar.  However it seems that it can not load the texture…



Texture t = TextureManager.loadTexture(SimpleGame.class

                .getClassLoader().getResource(fontLocation), Texture.MM_LINEAR,

                Texture.FM_LINEAR);



returns null.  So you seem to have identified the problem.  Now I just need to find out why this is not there.



edit: Changed the class loader… cut and past code (sigh)…

TextureManager.loadTexture(SimpleGame.class.getClassLoader().getResource(fontLocation), Texture.MM_LINEAR,

                Texture.FM_LINEAR)

Name of my class is SceneGraph… Wrong class loader…


How about the input system can I help?

So do you have the text working ok then?



As for the InputSystem, sure…  I was thinking we could either make AWTMouseInput and AWTKeyboardInput classes (extending com.jme.input.KeyInput and com.jme.input.MouseInput) or map the Mouse and Keyboard to LWJGL's input system.  The first way is probably more proper and perhaps easiest as well.



We may even want to put this awt dependant stuff into a jmex package so the awt dependancy (at least this one) sits outside of jme.

Text is working.



For the rest I willl try.