[SOLVED] Cursor does not move

I have implemented a handler which uses an AbsoluteMouse but my cursor is stuck in the bottom left corner of the screen and won't move… The code is as follows:

public class Rebedelho extends SimpleGame{

    private RebedelhoHandler input;

    public static void main(String[] args) {
        Rebedelho app=new Rebedelho();
        // Signal to show properties dialog

    protected void simpleInitGame() {
        UniverseBuilder bu = new UniverseBuilder(rootNode);

        //build the player input


    private void buildInput() {
        // Create the input handler
        input = new RebedelhoHandler(display.getRenderer(), rootNode);


The Handler code is here:

public class RebedelhoHandler extends InputHandler {

    private AbsoluteMouse mouse;

    public RebedelhoHandler (Renderer renderer, Node rootNode) {
        mouse = new AbsoluteMouse("Mouse Input", DisplaySystem.getDisplaySystem().getWidth(), DisplaySystem.getDisplaySystem().getHeight());
        mouse.registerWithInputHandler( this );
                // Getting a picture for the cursor
        Texture cursorTexture = TextureManager.loadTexture(Rebedelho.class.getClassLoader().getResource(
            "Models/cursor_rebel.png"), Texture.MinificationFilter.Trilinear,

        TextureState ts = renderer.createTextureState();

        BlendState alpha = renderer.createBlendState();



        // Get the position that the mouse is pointing to
        Vector2f screenPos = new Vector2f();
        // HotSpot: top left corner of the figure

    public AbsoluteMouse getMouse() {
        return mouse;

    public void MouseAction() {


I would also like to disable the free look feature: how do I do this?

I'm no AbsoluteMouse guru, but there are a few things we've done in our own implementation that I don't see in your code.

For starters, I think you should updateRenderState() on the AbsoluteMouse since you changed render state data.

I'm not sure this is needed, but we also put it in the ortho render queue (we don't want it going into the scene, now do we?): setRenderQueueMode(Renderer.QUEUE_ORTHO);

One last thing I don't see in your code is setting the translation of the new mouse to be close to the screen (and in this example in the middle of the screen: setLocalTranslation(new Vector3f(display.getWidth() / 2, display.getHeight() / 2, 1));

EDIT: You might also want to hide the normal mouse: MouseInput.get().setCursorVisible(false);

I tried all of these but couldn't get any result except for the cursor being immobile in the center of the screen…

The example I followed was the TestAbsoluteMouse.java in the jmetest.input package

public class TestAbsoluteMouse extends SimpleGame {

    private Text text;
    private AbsoluteMouse mouse;

    public static void main(String[] args) {
        TestAbsoluteMouse app = new TestAbsoluteMouse();

    protected void simpleUpdate() {
        text.print("Position: " + mouse.getLocalTranslation().x + " , "
                + mouse.getLocalTranslation().y);

    protected void simpleInitGame() {
        mouse = new AbsoluteMouse("Mouse Input", display.getWidth(), display
        TextureState cursor = display.getRenderer().createTextureState();

        text = Text.createDefaultTextLabel("Text Label", "Testing Mouse");
        text.setLocalTranslation(new Vector3f(1, 60, 0));
        BlendState as1 = display.getRenderer().createBlendState();

The strange part is that this code does not use anything like updateRenderState() or including the mouse in the RenderQueue...

I think the problem may be that I did not write all this code inside Rebedelho (which extends SimpleGame)... I'll try that now

I inserted the following code in the main class and it worked:

    protected void simpleUpdate () {
        // Mouse actions


I just found it strange that even when I did not override simpleUpdate or Update this input update was not done automatically as it was in the TestAbsoluteMouse example...

Ah, now I see.

Because you're using SimpleGame but using your own inputHandler that isn't updated with SimpleGame you get this problem.

In TestAbsoluteMouse it uses the inputHandler from BaseSimpleGame, which is updated in BaseSimpleGame.update (updateInput();). Since you're not using this inputHandler you have to update it yourself, like in the real setting.

Aah ok, that makes sense…! Thanks!

I still have one problem: when I move the mouse both the cursor and the camera move at the same time… How can I disable camera movement? When I use removeAllActions() in the input handler it stops the cursor movement but not camera movement…

I tried ((FirstPersonHandler) input).getMouseLookHandler().setEnabled(false) but I get an "inconvertible types" message

Have you checked out the HelloMousePick wiki yet?

Here is the wiki: http://www.jmonkeyengine.com/wiki/doku.php/starter:hello_mouse_pick_jme2:hello_mousepick

Nearly every Test class is written in SimpleGame, but the conversion to StandardGame and BaseGame isn’t too difficult.

Hope this helps!  :smiley:

Well, I found the problem… I declared my own inputhandler as input in the beginning of simplegame hoping it would override the existing attribute…

As it didn't, I had to rename this handler from input to input2 and then use

((FirstPersonHandler) input).getMouseLookHandler().setEnabled(false);