Problem with Game Canvas in Jframe

Hi,



I’m currently trying to display a Canvas in a JFrame window. I’m retrieving context of my SimpleApp and use the Canvas.startCanvas() function. The game is running because I can see the console answer to action, but the Canvas doesn’t display in the window.



Any idea what’s going on?

Check your layout, a BoxLayout is probably best.

I’m using an AWT canvas directly in the JFRAME ( in GUI designer ) that I set as my game canvas. You say that I should put the canvas in a BoxLayout to prevent it from disappearing?

that you set? you get a canvas from the application that you then attach to your window, yes. Read up on AWT/Swing layout.

I took example of the tutorial on Canvas and I did pretty much the same thing.



[java]

AppSettings settings = new AppSettings(true);

settings.setWidth(532);

settings.setHeight(560);

main.main.myGame.setSettings(settings);

main.main.myGame.setPauseOnLostFocus(false);





main.main.myGame.createCanvas();

JmeCanvasContext ctx = (JmeCanvasContext) main.main.myGame.getContext();

ctx.setSystemListener(main.main.myGame);

Dimension dimm = new Dimension(536, 566);

ctx.getCanvas().setPreferredSize(dimm);



GameCanvas = ctx.getCanvas();



main.main.myGame.startCanvas();



main.main.myInterface.setVisible(true);



[/java]



Where GameCanvas is an AWT canvas already placed/sized in my JFrame. Any idea why the canvas isn’t showing up? It’s up and running 'cause I see the systemPrint() in console when I press an action button.