0

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.setWidth(dim.width);
    settings.setHeight(dim.height);
    // settings.setRenderer(AppSettings.LWJGL_OPENGL1);

    setSettings(settings);
    createCanvas(); // create canvas!
    ctx = (JmeCanvasContext) getContext();
    ctx.setSystemListener(this);

    ctx.getCanvas().setPreferredSize(dim);
    startCanvas();

}

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

PanelDelAgente.add(agenteMolon.ctx.getCanvas());

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!

Transy
  • 59
  • 1
  • 1
  • 10

1 Answers1

0

In my case I use https://github.com/davidB/jme3_ext_swing

The question was also posted on the JME forum : https://hub.jmonkeyengine.org/t/putting-jme-canvas-into-jpanel-swing , with more answers.

David Bernard
  • 1,560
  • 13
  • 15