Are there any examples of a JMEDesktop?

I am currently using this code:

JMEDesktop myDesktop = new JMEDesktop("MyDesktop", 640, 480, true, null);
myDesktop.setRenderQueueMode (Renderer.QUEUE_ORTHO);
myDesktop.setLocalTranslation(new Vector3f (0,0,0));
myDesktop.setLightCombineMode(LightState.OFF);
myDesktop.updateRenderState();

myDesktop.getJDesktop().add (new JInternalFrame ("Frame", true, true, true, true));

rootNode.attachChild (myDesktop);



Which does absolutely nothing.  I have never used JDesktops in the past, so I don't really know if I am not using the JMEDesktop properly, or if I am just not adding anything to it.

Have a look at HelloJMEDesktop and TestJMEDesktop for simple examples.

You must set your JInternalFrame visible, and set a size and location for it.

See http://java.sun.com/docs/books/tutorial/uiswing/components/internalframe.html for details.

Thanks, I got it working.  Just another question, I have used the substance look and feel (and altered the examples to use substance), and I noticed that it changes the background of the quad to a dithered gray.  Is that normal?

691175002 said:
Is that normal?

Yes it is. At least I get the same results for the skins that are provided with substance.

Sorry about all these questions, but I can't figure out why this code sometimes culls the GUI quad:

Finally, is there a way to disable the mouse control of the camera in SimpleGame?

import javax.swing.JInternalFrame;
import javax.swing.UIManager;

import org.jvnet.substance.skin.SubstanceRavenGraphiteGlassLookAndFeel;

import com.jme.app.SimpleGame;
import com.jme.input.MouseInput;
import com.jme.renderer.Renderer;
import com.jme.scene.Node;
import com.jme.scene.SceneElement;
import com.jme.scene.state.LightState;
import com.jmex.awt.swingui.JMEDesktop;

public class GUITest extends SimpleGame {

   /**
    * @param args
    */
   public static void main(String[] args) {
      new GUITest().start();
   }
   
   protected void simpleInitGame () {
      MouseInput.get().setCursorVisible(true);
      try {
         //UIManager.setLookAndFeel(new SubstanceRavenGraphiteGlassLookAndFeel());
      } catch (Exception e) {
      }
      Node nGUI = new Node("Swing");
      nGUI.setRenderQueueMode(Renderer.QUEUE_ORTHO);

      JMEDesktop myDesktop = new JMEDesktop("desktop", display.getWidth(), display.getHeight(), input);
      nGUI.attachChild (myDesktop);

      myDesktop.getLocalTranslation().set(display.getWidth() / 2, display.getHeight() / 2, 0);

      //InternalPane
      JInternalFrame ipFrame = new JInternalFrame("MyFrame", true, true, true, true);
      myDesktop.getJDesktop().add(ipFrame);

      ipFrame.setVisible(true);
      ipFrame.setSize(500,500);

      rootNode.attachChild(nGUI);
      nGUI.setCullMode(SceneElement.CULL_NEVER);
      nGUI.setLightCombineMode(LightState.OFF);
      nGUI.updateRenderState();
      nGUI.updateGeometricState(0, true);
   }
}


I probbably should have done most of that from the swing thread but oh well.

Culling must be disabled for things in the ortho queue. Make sure the desktop itself and all nodes it resides in have CULL_NEVER state.

irrisor said:

Culling must be disabled for things in the ortho queue. Make sure the desktop itself and all nodes it resides in have CULL_NEVER state.


Would this include the root node?

Well, if you attach your desktop to the root node, yes. But you should not do that. fpsNode in SimpleGame or a custom node would be more suited.