Whether JFrame in Java can work in JME

Hello, I need to use jme to complete my final year project, but I am not very familiar with the jme.

I want to know whether the JFrame in java is still supported in JME? if not, what can I do if I want to create button, textfile and so on.

Thanks for your helps.

do you mean “is Swing supported in jme3?”

Are you asking if a jME canvas can be put on a JFrame? Yes.

Are you asking if a Swing JFrame can be rendered inside of a jME scene? Not out of the box (but some people have played with the concept)

1 Like

JME3 Canvas in a Swing GUI

Thanks for your helps. But my problem is that I’ve created the panels by using Nifty GUI and what I want to do next is to add menu list into the tool bar (can be achieved by using JMenuItem in Java Swing).

  • I want to know whether the menu list can be achieved by using Nifty GUI and how to achieve?
  • whether the JMenuItem can be embedded into the panel created by the Nifty GUI?

    Thanks again

You seem to be trying to work around nifty, instead of checking if the functionality already exists in nifty. Unless you have a specific reason to use swing, I would recommend using pure nifty. Nifty can do a lot more than just layout your panels, and a framework for interaction between your environment and your gui already exists for Nifty… If you do insist on using swing, you may want to investigate if there will be any concurrency issues…

But in the end I think you would complicate things for your self if you want to overlay swing onto nifty. Could you not just use the “popup” functionality that is provided by nifty to show a menu once a button bound to the top of the window is clicked?

Thanks nihal.

I don’t insist on using swing and I just don’t know how to accomplish the menu list in Nifty. It will be great if you can tell me how to accomplish the function by using Nifty. You referred to “popup” functionality, do you have sample code showing this function? And where can I find all the functionality that Nifty provided? Thanks a lot.


Might also be worth having a look at the Nifty bible: http://kent.dl.sourceforge.net/project/nifty-gui/nifty-gui/nifty-gui-the-manual-v1.0.pdf

Popups are explained on page 41, but I’d recommend reading all of it. Takes about a day to read in detail, but it is worth it.

Thank you very much! I appreciate both of your recommends. And one short question:

I found most of the JME products are just displaying the scene that the developer has created during programming.

I want to know whether there will be one kind of sample to allow the user to create the scene. For example, the user clicks on “Box” in the menu, then there will be a box appearing in the scene. Click again, there will be another box in the scene.

Look forward to your reply. Thanks.

If you mean the user as in “you”, then your answer is the SDK. https://wiki.jmonkeyengine.org/legacy/doku.php/sdk

If you mean the user as in “the people using the application you write”, that’s functionality that you can very easily write and jME provides all the tools to do it. Just read the documentation. http://hub.jmonkeyengine.org/wiki

I don’t have a ready example, but it would be very easy to make. In nifty you will need to setup a controller, which is the java class on which you call methods when the user interacts with an element. Use one of those methods to add a box to the scene.

Try to get this example to work, and I am sure you will understand:


Like another topic I posted, I’ve changed my codes during the instruction in the ‘Nifty GUI java interaction’ part. But I still cannot put a 3d scene into the panel by clicking a button. I thinks may be it is because I don’t point out one specific panel that the scene should be displayed. But I don’t know the code to point out a panel to display.

The following are some screenshots of my program and look forward to your kindly helps.