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?



-mike

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:


 display.setTitle("OpenMOG");
        scene = new Node("Scene graph node init");
        buildInput();
        gui = new ClientGUI(this);
        gui.makeConnectGUI();
     
   
        makeCursor();
      
        scene.updateGeometricState(0.0f, true);
        scene.updateRenderState();




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");
            return;
        }
        jmeDesktop = new JMEDesktop( "test internalFrame" );
        jmeDesktop.getLocalTranslation().set(display.getWidth()/2,display.getHeight()/2,0);
        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.setCullMode(Spatial.CULL_NEVER);
        desktopNode.setLightCombineMode( LightState.OFF);
   
       
       
        jmeDesktop.getJDesktop().setBackground( new Color( 0, 1, 1, 1f ) );
       
        makeConnectFrame();
        jmeDesktop.getJDesktop().repaint();
        jmeDesktop.getJDesktop().revalidate();
        desktopNode.updateRenderState();
         desktopNode.updateGeometricState( 0, true );





  private void makeConnectFrame()
    {
        connectFrame = new ConnectFrame(client);
        connectFrame.setLocation(100,300);
        connectFrame.setVisible(true);
        jmeDesktop.getJDesktop().add(connectFrame);
    }






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();
        setLayout(gridbag);
       
        nameLabel.setLabelFor(nameField);
        passwordLabel.setLabelFor(passwordField);
       
        add(nameLabel, con);
        add(nameField, con);
        add(passwordLabel, con);
        add(passwordField, con);
        connectButton.setSize(50,50);
        connectButton.addActionListener(this);
        add(connectButton, con);
        setSize(300,200);
        pack();
       
       
    }
   
    public void actionPerformed(ActionEvent e) {
       
        if (!client.network.isConnected())
           {
               String name = nameField.getText();
               String password = new String(passwordField.getPassword());
               System.out.println("Grabbed Name/PW: "+ name + " " + password);
               client.network.connect("0.0.0.0", 8888);
               client.network.sendMessage(Messages.MSG_CONNECT_ZONE + " "+name+" hash");
           }
    }
}




Any ideas?

-Mike

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


        makeConnectFrame();
        jmeDesktop.getJDesktop().repaint();
        jmeDesktop.getJDesktop().revalidate();


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