i have implemented keylistener as well as actionlistener.
action listener is working but not the keylistener even after doing setFocusable(true); ,please help me

this is the code
Code:
import java.awt.*;
import java.awt.event.*;
public  class Paint extends JPanel implements KeyListener,ActionListener
	{	boolean collision = false;
		Rect rect1;
		Rect rect2;
		Rect rect3;
		Timer time;
		public static void main(String[] args)
	{
		JFrame f = new JFrame();
		f.setVisible(true);
		f.setSize(700,700);
		Paint p = new Paint();
		f.add(p);
	}
		public Paint()
		{
			rect1=new Rect(0,20,100,50);
			rect2=new Rect(600,20,100,50);
			rect3=new Rect(0,30,50,50);
			time=new Timer(4,this);
			time.start();
			JPanel.addKeyListener(this);
			JPanel.setFocusable(true);
		}
		public void actionPerformed(ActionEvent ex)
		{
			rect1.move();
			rect2.move();
			collision();
			repaint();
		}
		public void collision()
		{
			Rectangle rectangle1=rect1.bounds();
			Rectangle rectangle2=rect2.bounds();
			Rectangle rectangle3=rect3.bounds();
			if ((rectangle2 . intersects (rectangle1)) || (rectangle2. intersects(rectangle3)))
				collision = true;
			else
				collision = false;
		}
		public void paint(Graphics g)
		{
			super.paint(g);
			Graphics2D g2d=(Graphics2D)g;
			g2d.setColor(Color.blue);
			g2d.fillRect(rect1.x,rect1.y,100,50);
			g2d.setColor(Color.pink);
			g2d.fillRect(rect2.x,rect2.y,100,50);
			g2d.setColor(Color.black);
			g2d.fillRect(rect3.x,rect3.y,rect3.width,rect3.height);
			if (collision)
			g2d.drawString("Collision",350,50);
		}
		
		public void keyPressed(KeyEvent e)
 		{
			 int keyCode = e.getKeyCode();
			
			 if(keyCode == KeyEvent.VK_LEFT)
 			{
				 rect3.x -= 1;
				 repaint();
			 }
			 else if(keyCode == KeyEvent.VK_RIGHT)
 			{
 				rect3.x += 1;
				/* if(rect3.x > getSize().width-rect3.width)
				 {
					 rect3.x = getSize().width-rect3.width;
				 }*/
 				repaint();
 			}
 			else if(keyCode == KeyEvent.VK_UP)
			 {
				 rect3.y -= 1;
				// if(rect3.y < 0) rect3.y = 0;
 				repaint();
 			}
 			else if(keyCode == KeyEvent.VK_DOWN)
 			{
				 rect3.y += 1;
				/*if(rect3.y > getSize().height-rect3.height)
 				{
					 rect3.y = getSize().height-rect3.height;
				 }*/
 				repaint();
 			}
			
		}	
			public void keyReleased(KeyEvent e){}
			 public void keyTyped(KeyEvent e){}

	}