I have a Swing GUI app and I want to render 3D stuff using jME inside a Canvas/JPanel. I couldn’t find information about this but I found that StandardGame seem to be capable of doing this. Do you guys know about any existing tutorial?
Thanks.
There is examples for this in the source code of both jme2 and jme3, look inside the jmetest package. Also, you should be able to find more information on the topic in the forum: http://hub.jmonkeyengine.org/forums/?fs=jme+canvas
Cheers,
Normen
Here’s a test:
package test;
import com.jme3.app.SimpleApplication;
import com.jme3.system.AppSettings;
import com.jme3.system.JmeCanvasContext;
import java.awt.Dimension;
import javax.swing.JFrame;
public class SwingCanvasTest extends SimpleApplication {
@Override
public void simpleInitApp() {
//here you can write your app
}
public static void main(String[] args) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
AppSettings settings = new AppSettings(true);
settings.setUseInput(false);
settings.setWidth(640);
settings.setHeight(480);
SwingCanvasTest canvasApplication = new SwingCanvasTest();
canvasApplication.setSettings(settings);
canvasApplication.createCanvas();
JmeCanvasContext ctx = (JmeCanvasContext) canvasApplication.getContext();
ctx.setSystemListener(canvasApplication);
JFrame window = new JFrame(“Test Application”);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.add(ctx.getCanvas());
Dimension dim = new Dimension(640, 480);
ctx.getCanvas().setPreferredSize(dim);
window.pack();
window.setVisible(true);
canvasApplication.startCanvas();
}
});
}
}
The canvas component is the one you get from “ctx.getCanvas()”
Oh, thanks guys. I finally got to find the sample, I’ll try to play around with it.
Thanks again