problem keylistener java (4 posts)

  • Profile picture of riuzaki90 riuzaki90 said 3 months, 3 weeks ago:

    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.

  • Profile picture of normen normen1290p said 3 months, 3 weeks ago:

    Look at TestAwtPanels

  • Profile picture of riuzaki90 riuzaki90 said 3 months, 3 weeks ago:
    	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();
                  }
            });
    
    	}

    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?

  • Profile picture of normen normen1290p said 3 months, 3 weeks ago:

    @normen said:
    Look at TestAwtPanels