[SOLVED] Custom mouse cursor disappearing in fullscreen mode

Hi there!

I’m implementing a 3D real time strategy game. When a user wants to create a new building, I want to change the mouse cursor, depending on if the building can be built at the current mouse position.

I followed this example for changing the cursor, and it worked quite fine:
jmonkeyengine/jme3-examples/src/main/java/jme3test/gui/TestCursor.java at master · jMonkeyEngine/jmonkeyengine · GitHub.

But when I run the application in full screen mode, the mouse cursor disappears! I can click on the items and move around. That all works, but with an invisible mouse cursor.

This is the method with which I change my display settings:

     * Use AWT to get the possible screen resolutions. Usually, the resolutions are ordered from small to large.
     * This method uses the very last resolution in fullscreen (if supported).
     * NOTE: This method may not run on macOS.
    public void setToFullScreenWindows(OffToNewWorlds offToNewWorlds) {

        GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
        DisplayMode[] modes = device.getDisplayModes();

        AppSettings appSettings = OffToNewWorldsSettings.get().getAppSettings();

        int modePos = modes.length - 1;
        appSettings.setResolution(modes[modePos].getWidth(), modes[modePos].getHeight());

As soon as I remove the line “appSettings.setFullscreen”, the mouse cursor is visible again.

Anybody got an idea?


Hi @holleymcfly. Welcome to the jungle.

To give a concrete solution it is better to create a simple example where this error occurs, since with a code fragment it is difficult to determine what is happening (I can only speculate)

Are you sure you’re getting the right resolution for your full screen?


GraphicsDevice device = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
DisplayMode[] modes = device.getDisplayModes();

It will not return sorted resolutions, that is, the last resolution contained in the array may not be the correct resolution…

You can also try uploading an image (PNG) as a cursor:

    protected void setImageCursor(String imageStr) {
        Texture cursorTexture = assetManager.loadTexture(imageStr);

        Image image = cursorTexture.getImage();
        ByteBuffer imgByteBuff = (ByteBuffer) image.getData(0).rewind();
        IntBuffer curIntBuff = BufferUtils.createIntBuffer(image.getHeight() * image.getWidth());

        while (imgByteBuff.hasRemaining()) {
            int rgba = imgByteBuff.getInt();
            int argb = ((rgba & 255) << 24) | (rgba >> 8);

        JmeCursor c = new JmeCursor();
        c.setyHotSpot(image.getHeight() - 3);
        c.setImagesData((IntBuffer) curIntBuff.rewind());

1 Like

Hi SwiftWolf!

Thank you for your welcome & answer!

First, the working example was the TestCursor.java example I posted in the first place, only with setting the display I added there. Sorry, I could have figured that out better.

Second, yes, currently I always get the correct resolution. However, I have run the application only on one single laptop up to now. I’m aware that this is not a perfect solution and I will have to rework it later.

And the best is: although I still do not know what’s going wrong using the .cur files, taking your example works! I’m just using the JmeCursor from the png file as written by you, instead of the cur file, the rest is pretty much the same.

Thanks again, this issue is resolved from my point of view.

Holger (Holley)

1 Like

Btw: how do I mark this issue as solved?

Btw: how do I mark this issue as solved?

You can edit your title and put [SOLVED] in it if you like.

Thanks again, this issue is resolved from my point of view.

Glad you’ve found a work around! It is odd though, if I edit that TestCursor.java example to show the options, and when it boot tick “full screen” it works fine for me with the 3 cursors.


Maybe something specific to your graphics card?

Thanks for the hint regarding [SOLVED] - things can be so easy :slight_smile:

Yes, it’s surely just a work around. But I think I won’t figure out the main cause for the problem - at least for now… Maybe I will test it on some other laptop to check if it is the same there.

1 Like