Problem keylistener java

Hi guys…I’m developing a game (minigolf) with JM3 and I’m including the simpleapplication with the scene into a jpanel, because I’ve all the menu graphic with SWING…now I want to know how can I wrap the keylistener of java to use it in the panel with the JM class.



thanks in advance.



simply add(new KeyListener()); to the context of the application dosen’t work.

Look at TestAwtPanels

[java] public SinglePlayer3D(final MainScreen mainScreen, int width, int height) {



this.mainScreen = mainScreen;

this.setSize(width, height);

this.setVisible(true);

this.gameManager = new SingleManager(“Luca”, “Asino”, “field”, “3”);

world_designer = new World3D(gameManager);

//this.addKeyListener(key = new keyListenerManager(gameManager));



java.awt.EventQueue.invokeLater(new Runnable()

{

public void run()

{

AppSettings settings = new AppSettings(true);

settings.setWidth(1024);

settings.setHeight(710);



world_designer.setSettings(settings);

world_designer.createCanvas(); // create canvas!

ctx = (JmeCanvasContext) world_designer.getContext();

ctx.setSystemListener(world_designer);

Dimension dim = new Dimension(1024, 700);

ctx.getCanvas().setPreferredSize(dim);

ctx.getCanvas().addKeyListener(new keyListenerManager(gameManager));

mainScreen.getWindow().add(ctx.getCanvas());

mainScreen.getWindow().setVisible(true);

world_designer.startCanvas();

}

});



}[/java]

this is the constructor of my singleplayer class…how can I modify the run() method to can use the listener that I’ve comment up in the constructor?

@normen said:
Look at TestAwtPanels