(Beginner)Problems with JMEDesktop

Here`s the english version, sorry again.


I tried to make a simple JMEDesktop GUI for a game. For a first test, I tried the code from HelloJMEDesktop in  /jme/src/jmetest/awt/swingui/

But I had some problems.

This is HelloJMEDesktop:

 * Very short example for JMEDesktop - see {@link TestJMEDesktop} for more features.
public class HelloJMEDesktop extends SimpleGame {
    private static final Logger logger = Logger.getLogger(HelloJMEDesktop.class

    private Node guiNode;

    protected void simpleInitGame() {
        // create a node for ortho gui stuff
        guiNode = new Node( "gui" );
        guiNode.setRenderQueueMode( Renderer.QUEUE_ORTHO );

        // create the desktop Quad
        final JMEDesktop desktop = new JMEDesktop( "desktop", 500, 400, input );
        // and attach it to the gui node
        guiNode.attachChild( desktop );
        // center it on screen
        desktop.getLocalTranslation().set( display.getWidth() / 2 - 30, display.getHeight() / 2 + 50, 0 );

        // perform all the swing stuff in the swing thread
        // (Only access the Swing UI from the Swing event dispatch thread!
        // See SwingUtilities.invokeLater()
        // and http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html for details.)
        SwingUtilities.invokeLater( new Runnable() {
            public void run() {
                // make it transparent blue
                desktop.getJDesktop().setBackground( new Color( 0, 0, 1, 0.2f ) );

                // create a swing button
                final JButton button = new JButton( "click me" );
                // and put it directly on the desktop
                desktop.getJDesktop().add( button );
                // desktop has no layout - we layout ourselfes (could assign a layout to desktop here instead)
                button.setLocation( 200, 200 );
                button.setSize( button.getPreferredSize() );
                // add some actions
                // standard swing action:
                button.addActionListener( new ActionListener() {
                    public void actionPerformed( ActionEvent e ) {
                        // this gets executed in swing thread
                        // alter swing components ony in swing thread!
                        button.setLocation( FastMath.rand.nextInt( 400 ), FastMath.rand.nextInt( 300 ) );
                        logger.info( "clicked!" );
                } );
                // action that gets executed in the update thread:
                button.addActionListener( new JMEAction( "my action", input ) {
                    public void performAction( InputActionEvent evt ) {
                        // this gets executed in jme thread
                        // do 3d system calls in jme thread only!
                        guiNode.updateRenderState(); // this call has no effect but should be done in jme thread :)
        } );

        // don't cull the gui away
        guiNode.setCullHint( Spatial.CullHint.Never );
        // gui needs no lighting
        guiNode.setLightCombineMode( Spatial.LightCombineMode.Off );
        // update the render states (especially the texture state of the deskop!)
        // update the world vectors (needed as we have altered local translation of the desktop and it's
        //  not called in the update loop)
        guiNode.updateGeometricState( 0, true );

        // finally show the system mouse cursor to allow the user to click our button
        MouseInput.get().setCursorVisible( true );

    protected void simpleRender() {
        // draw the gui stuff after the scene
        display.getRenderer().draw( guiNode );

    public static void main( String[] args ) {
        new HelloJMEDesktop().start();

I think it's not necessary to insert my file here, its too long and I used, for the GUI, exactly this code. My first 2 problems did happen too, when running directly HelloJMEDesktop.

The problems:
- The background is offen not displayed. It appears then when I click the button, in the space between its old and new position. Sometimes it's correctly displayed (from the moment when I start the game).
- The button is displayed the first time when I go with the mouse over it. Before that it's not visible.
- When I click the button, I still click the terrain behind it. In my case, this makes that the maincharacter walks to the position where I clicked. I would like to click just the GUI, not what is behind it. Things around the GUI should althought be enabled, when the GUI is opened.
I'm new to JMEDesktop, so I don't have any idea right now how this could be made.

Would be thankful for every advice.

P.D. I decided to use JMEDesktop, because I didn't manage to show the GUI correctly with Fenggui, and didn't find good documentation on GBUI. I don't have experience with any of them, and would be thankful too, if anybody could give me an advice what to use. Did already read the thread about which GUI to use, but couldn't come to any conclusion, for which one could be useful for me. I don't have experience with any GUIs for JME right now, so would be great if there where some tutorials.


Da ich selbst JMEDesktop nicht benutze, weil es auf MacOS nicht vern

... dass dieses Forum englischsprachig ist ...

Wobei ein grosser Teil der Forum-User eh Deutschsprachig sind ;)

Aber wie normen schon sagt, evt ists besser gleich von Anfang an auf GBUI (und english) zu wechseln.

omg… forgot totally about the language… going to translate it right now… sorry!!!

I will try with GBUI.