jmeDesktop not updating/repainting

Okay im slowly getting my code migrated to jme .10 when I have free time and I have come across an odd issue.

The swing portion will not update/repaint.  I used to be able to drag windows, enter text, etc and watch it happen.

Now to see the changes i need to change focus to another application then go back into my application and i see the changes applied.

Any ideas on what this could be?


you are migrating from jME 0.9 to 0.10?

If yes that's really strange, as there was no JMEDesktop in 0.9 :roll:

As a first step, please check that TestJMEDesktop runs fine on your system.

Yes the test jmedesktop and the hello jmedesktop both work.  The version of jme I was using before I got in Febuary, and it wasn't .10.

Also I do not know why hello jmedesktop uses swings invoke later to make sure some swing commands are run from the swing thread yet the test jmedesktop does not do this.

Swing stuff should always be called from the swing thread. TestJMEDesktop (and your app) should do it this way, too. Where do you think this is not the case? I think in TestJMEDesktop the only thing that gets executed in the jME thread is the creation of components - which still works because of the revalidate and repaint calls at the end. It is better to use invokeLater though. So HelloJMEDesktop shows the way to go.

If you also do not use invokeLater (or code in a swing action) to alter the swing gui this could explain the repaint problems. Try to execute that code in the swing thread then, or as a workaround call repaint afterwards.

Does swing.InvokeLater or the other swing invoke command have to be used for code to be run from the swing thread?

My app is a FixedLogicRateGame.  This is my initGame where I make the gui:

        scene = new Node("Scene graph node init");
        gui = new ClientGUI(this);
        scene.updateGeometricState(0.0f, true);

ClientGUI.makeConnectGUI(): (I've tried putting much of this in a swing.invokeLater call and it did not help)

 DisplaySystem display = client.getDisplay();
        Node scene = client.getScene();
        if ( scene == null)
            System.out.println("Makegui null scene");
        jmeDesktop = new JMEDesktop( "test internalFrame" );
        jmeDesktop.setup( display.getWidth(), display.getHeight(), false, client.getInput() );
        jmeDesktop.setLightCombineMode( LightState.OFF );
        jmeDesktop.setCullMode( Spatial.CULL_NEVER );

        desktopNode = new Node( "desktop node" );
        desktopNode.attachChild( jmeDesktop );
        jmeDesktop.setRenderQueueMode( Renderer.QUEUE_ORTHO );
        scene.attachChild( desktopNode );
        desktopNode.setLightCombineMode( LightState.OFF);
        jmeDesktop.getJDesktop().setBackground( new Color( 0, 1, 1, 1f ) );
         desktopNode.updateGeometricState( 0, true );

  private void makeConnectFrame()
        connectFrame = new ConnectFrame(client);

public class ConnectFrame extends JInternalFrame implements ActionListener {
    private JButton connectButton = new JButton("Connect");
    Client client;
    private JTextField nameField = new JTextField(20);
    private JPasswordField passwordField = new JPasswordField(20);
    private JLabel nameLabel = new JLabel("Name: ");
    private JLabel passwordLabel = new JLabel("Password: ");

    /** Creates a new instance of ConnectFrame */
    public ConnectFrame(Client c) {
        super("Connect", false, false, false, false);
        client = c;
        GridBagLayout gridbag = new GridBagLayout();
        GridBagConstraints con = new GridBagConstraints();
        add(nameLabel, con);
        add(nameField, con);
        add(passwordLabel, con);
        add(passwordField, con);
        add(connectButton, con);
    public void actionPerformed(ActionEvent e) {
        if (!
               String name = nameField.getText();
               String password = new String(passwordField.getPassword());
               System.out.println("Grabbed Name/PW: "+ name + " " + password);
     "", 8888);
      + " "+name+" hash");

Any ideas?


Only these lines must be put into the swing thread (e.g. invokeLater) :


The rest of the init method is GL related and must stay in the main thread.

Irrisor thanks for explaining what should be called from the swing thread.

I seem to have fixed the problem.  What solved it was NOT adding the gui node to the scene node.

glad you fixed it