Swing and jME

Good day,



(note: this may be a stupid question)

I have no real experience in GUI creation.  But since jME has no GUI package, I was wondering if it would be possible to integrate Swing and JME in a common console?



Else, should I consider NUI or BUI since none is officially part of jME?








Looks like everybody hates GUIs…



Humm…



My test:

  • I want to have a panel that I can scroll (up and down). In that panel, I want to add items dynamically (sort of a List). 
  • Each item is composed of a name, a picture, and an editable box.

    Ideally I would like to be able to pick one item and mive it up/down in the list.



    Any suggestions?



    I looked at the BUI, there are some classes there that would allow creation of a panel with scrolling, however it is in the jmex package.  Does it mean anything?  Is samskivert still around?

Any reasons why I get no answer?



Are there any plans to integrate SWING in jME? 



Is it possible ?



Any plans for GUIs?

You can already do Swing with jME (see jmetest.util.JMESwingTest for an example).



All UI code is being removed from the baseline currently both widget and ui. What's there is old and stagnant. BUI/NUI is more likely what you'll want.

I will look at that example.



The only thing I found so far was the Particle generator example that used SWING but displayed the output in two different consoles (one for SWING components, and one for the scenegraph). 

That's actually being revamped due to the ui removals mentioned above

Just tried the JMESwingTest, this is great!!



Thanks.

Good, glad to hear it. Make sure you let us know of any bugs, improvements etc. You are the first that's going to make extensive use of it… the guinea pig. :slight_smile:

BTW: Is there a way to hide the canvas until a certain point like until all models are loaded, etc. ?



I have to present a JDialog to ask for server name and login and I would like to keep it as a kind of splash screen until the game is ready to be used. Currently I use SimpleGame and the scene is loaded in simpleInitGame().

At the end I would like to dispose the dialog and present the 3d screen.



Is that possible?

Hmm, have you tried simply not adding the Canvas to your GUI until after the login?  Or making use of setVisible?

As far as I can see, this is all hidden in SimpleGame. In initSystem() it creates the window, sets the background and so on.

It looks like I have to use BaseGame instead and do all the initialization on my own  :frowning:



But that is quite some work just to find out whether it can be done that way.

SimpleGame is an easy way to to test out your game with standard camera controls and other things that allow you to work with the world and be able to see what you've accomplished.  It is not intended to be put in the final release of any games.  That seems to be a common misconception.  You'll definitely want to look into BaseGame or AbstractGame when you actually write your own games.



darkfrog

Regardless of which game type you use, you have complete control over the Swing elements of your game.  You decide when to add the JMECanvas to your awt or swing UI.

Ok, now I tried the BaseGame class and in initSystem() I have:



display = DisplaySystem.getDisplaySystem(properties.getRenderer());

Canvas canvas = display.createCanvas(properties.getWidth(),properties.getHeight());



If I try to load the scene after that line I get a null pointer exception in scene.Geometry.

The model loads without problems if I create a window before but then I loose the control over when the 3d display should appear.



So this works:

display = DisplaySystem.getDisplaySystem(properties.getRenderer());

display.createWindow(properties.getWidth(),properties.getHeight(),properties.getDepth(),

  properties.getFreq(),properties.getFullscreen());

// load the scene here



I'm quite sure I'm missing something simple here.

Can you give us a stacktrace for the NPE?  Thanks.



java.lang.NullPointerException

        at com.jme.scene.Geometry.<init>(Unknown Source)

        at com.jme.scene.TriMesh.<init>(Unknown Source)

        at com.jmex.model.XMLparser.JmeBinaryReader.readBegining(Unknown Source)



        at com.jmex.model.XMLparser.JmeBinaryReader.loadBinaryFormat(Unknown Source)

        at com.jmex.model.XMLparser.JmeBinaryReader.loadBinaryFormat(Unknown Source)

        at de.worldofmystery.client.Client.loadScene(Client.java:126)

        at de.worldofmystery.client.Client.simplePreload(Client.java:136)

        at de.worldofmystery.client.WomGame.initSystem(WomGame.java:89)

        at com.jme.app.BaseGame.start(Unknown Source)

        at de.worldofmystery.client.Client.main(Client.java:93)





where loadScene and simplePreload look like:



Node scene;



public void loadScene()

{

        URL model=Client.class.getClassLoader().getResource("data/model/building.jme");

        //display = DisplaySystem.getDisplaySystem("LWJGL");

        JmeBinaryReader jbr=new JmeBinaryReader();

        try {

            // Tell the binary reader to use bounding boxes instead of bounding spheres

            jbr.setProperty("bound","box");

            // Load the binary .jme format into a scene graph

        jbr.setProperty("texurl",new URL(model.getProtocol()+":"+model.getPath()));

            scene=jbr.loadBinaryFormat(model.openStream());

        } catch (IOException e) {

            System.out.println("Cannot load model: " + e);

            e.printStackTrace();

            System.exit(0);

        }

}



protected void simplePreload()

{

loadScene();

}

The problem is it is trying to determine the max tex units before a Renderer is created.  In the swing stuff, the Renderer is initiated on the first paint.  You might consider adding the canvas with your Implementor first, just don't have it render anything (ie, don't put anything in the scene until you are ready.)

Cool, glad you are enjoying jME with the rest of us…  Spread the word.  :smiley:



I take it you are using cvs jME, so I'm perplexed by the responsiveness thing.  The yield in the repaint thread generally does the trick.  On the systems I can test here, it is pretty quick to pull up the color picker and the bg color changes right away.  hmmm…

Im using Sun SE 1.4.2_10, running on win XP. Used the source from cvs yesterday, built with ant.

Tested the demo once again, and took 15 seconds to show the dialog.  Agree that yield should fix that. Strange.



I will spread the word… We are 3 developers here in the development department of this company that will be using jME. We are in the scientific / industrial domain, and will for sure impress customers with our 3D scene and HUD displays.



We are a bit worried about support… This forum is very active, but I will still look for a jME developer getting paid to help us out now and then.