I followed the tutorial for using swing with JMonkey and got the example working however I’m having trouble getting it to work with my JFrame I created using the Netbeans GUI. I’m not very familiar with swing so perhaps I’m missing something simple. I appreciate any help.
public static void main(String[] args) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
AppSettings settings = new AppSettings(true);
settings.setWidth(640);
settings.setHeight(480);
Main canvasApplication = new Main();
canvasApplication.setSettings(settings);
canvasApplication.createCanvas(); // create canvas!
JmeCanvasContext ctx = (JmeCanvasContext) canvasApplication.getContext();
ctx.setSystemListener(canvasApplication);
Dimension dim = new Dimension(640, 480);
ctx.getCanvas().setPreferredSize(dim);
JFrame window = new FrameWorldEdit();
window.add(ctx.getCanvas());
window.pack();
window.setVisible(true);
canvasApplication.startCanvas();
}
});
}
This produces my JFrame , which has zero components for testing , and no canvas.