Putting JME canvas into JPanel SWING

Hello everybody.

I need to put a JME canvas into my app JPanel.

In the class with JME I init this:

public JmeCanvasContext ctx;
public Dimension dim = new Dimension(800, 600);
private void init() {
    AppSettings settings = new AppSettings(true);
    // settings.setRenderer(AppSettings.LWJGL_OPENGL1);

    createCanvas(); // create canvas!
    ctx = (JmeCanvasContext) getContext();



Then, in my main Window I create a JPanel (using NEtbeans designer tool) and add my jme canvas to the panel.


But doesntwork. Is the first time that I use JME and I dont know very well how can I put it in a Jpanel

Thanks for your time!

Take a look at the JME examples (bundled with your SDK if you create a test project). In there are various examples of using a canvas or using the AWTPanels (the preferred way).

As a alternative, use by few monkeys. You can try jme3_ext_swing. no AWT or Canvas. Jme render offscreen and the image is copyied into a JPanel. interaction also work (the sample include a mouse picker).