Maze game adding player issue : <blockquote>
  <p>Giving me a Syntax error that "cannot find MyKeyListener". I am trying to add it so player class can be implemented into the grid.So far i have created both player and maze but cant seem able to add player to maze because of this syntax error. Can anyone point out what mistake i am making.</p>
</blockquote>

<pre><code>import java.awt.*;
import javax.swing.*;
import java.awt.event.*;  // Needed for ActionListener
import javax.swing.event.*;  // Needed for ActionListener
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.ActionListener;
import javax.swing.JPanel;
import javax.swing.Timer;

public class www extends JFrame
{
    static Maze maze = new Maze ();
    static Timer t;

    //======================================================== constructor
    public www ()
    {
        // 1... Create/initialize components
        // 2... Create content pane, set layout
        JPanel content = new JPanel ();        // Create a content pane
        content.setLayout (new BorderLayout ()); // Use BorderLayout for panel
        JPanel north = new JPanel ();
        north.setLayout (new FlowLayout ()); // Use FlowLayout for input area

        DrawArea board = new DrawArea (500, 500);

        // 3... Add the components to the input area.

        content.add (north, "North"); // Input area
        content.add (board, "South"); // Output area

        // 4... Set this window's attributes.
        setContentPane (content);
        pack ();
        setTitle ("MAZE");
        setSize (490, 500);
        setKeyListener(new MyKeylistener());
        setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
        setLocationRelativeTo (null);           // Center window.
    }

    public static void main (String[] args)
    {
        www window = new www ();
        window.setVisible (true);

        //jf.setTitle("Tutorial");
        //jf.setSize(600,400);

    }

    class DrawArea extends JPanel
    {
        public DrawArea (int width, int height)
        {
            this.setPreferredSize (new Dimension (width, height)); // size
        }

        public void paintComponent (Graphics g)
        {
            maze.show (g); // display current state of colony
        }
    }
}

class Maze 
{
    private int grid [][];

    public Maze ()
    {
        int [][] maze = 
            { {1,0,1,1,1,1,1,1,1,1,1,1,1},
                {1,0,1,0,1,0,1,0,0,0,0,0,1},
                {1,0,1,0,0,0,1,0,1,1,1,0,1},
                {1,0,0,0,1,1,1,0,0,0,0,0,1},
                {1,0,1,0,0,0,0,0,1,1,1,0,1},
                {1,0,1,0,1,1,1,0,1,0,0,0,1},
                {1,0,1,0,1,0,0,0,1,1,1,0,1},
                {1,0,1,0,1,1,1,0,1,0,1,0,1},
                {1,0,0,0,0,0,0,0,0,0,1,0,1},
                {1,1,1,1,1,1,1,1,1,1,1,0,1}};

        grid = maze;

    }

    public void show (Graphics g)
    {
        for (int row = 0 ; row &lt; grid.length ; row++)
            for (int col = 0 ; col &lt; grid [0].length ; col++)
            {
                if (grid [row] [col] == 1) // life
                    g.setColor (Color.black);
                else
                    g.setColor (Color.white);
                g.fillRect (col * 30 + 30, row * 30 + 30, 30, 30); // draw life form

            }
        //g.setColor(Color.RED);
        //g.fillRect(60,30,30,50);

    }

    class MyKeyListener extends KeyAdapter {

        int x =  0, y = 0,velX = 0, velY = 0;
        public void keyPressed(KeyEvent e)
        {
            int c =  e.getKeyCode();
            if(c == KeyEvent.VK_LEFT)
            {
                velX = -1;
                velY = 0;
            }
            if (c == KeyEvent.VK_UP)
            {
                velX = 0;
                velY = -1;
            }
            if( c==KeyEvent.VK_RIGHT)
            {
                velX = 1;
                velY = 0;
            }
            if(c==KeyEvent.VK_DOWN)
            {
                velX = 0;
                velY = 1;
            }
        }

        public MyKeyListener ()
        {
            tm.start ();    
            addKeyListener(this);
            setFocusable(true);
            setFocusTraversalKeysEnabled(false);
        }

        public void paintComponent(Graphics g)
        {
            super.paintComponent(g);
            g.setColor(Color.RED);
            g.fillRect(x,y,50,30);

        }

        public void actionPerformed(ActionEvent e)
        {
            x = x+velX;
            y = y +velY;
            repaint();
        }


    }

    //     public void player ()
    //     {
    // 
    //         Timer tm = new Timer(5,this);
    //          int x = 0; 
    //           int y = 0;
    //          int velX = 0 ;
    //          int velY = 0;tm.start();
    //         addKeyListener(this);
    //         setFocusable(true);
    //         setFocusTraversalKeysEnabled(false);
    //     }

    //     public void actionPerformed(ActionEvent e)
    //     {
    //         x = x+velX;
    //         y = y +velY;
    //         repaint();
    //     }

    //     public void keyPressed(KeyEvent e)
    //     {
    //         int c =  e.getKeyCode();
    //         if(c == KeyEvent.VK_LEFT)
    //         {
    //             velX = -1;
    //             velY = 0;
    //         }
    //         if (c == KeyEvent.VK_UP)
    //         {
    //             velX = 0;
    //             velY = -1;
    //         }
    //         if( c==KeyEvent.VK_RIGHT)
    //         {
    //             velX = 1;
    //             velY = 0;
    //         }
    //         if(c==KeyEvent.VK_DOWN)
    //         {
    //             velX = 0;
    //             velY = 1;
    //         }
    //     }
    // 
    //     public void keyTyped(KeyEvent e){}
    // 
    //     public void keyReleased(KeyEvent e){}

}
</code></pre>
