I am working on a project that simulates a traffic intersection. So far I did the map, traffic lights. Now I want to add some movement, some cars in my project. The problem that I am facing is that i can't add graphics on the same Panel from different classes. And can someone give me a good tutorial where I can learn how to move multiple graphics (cars in my case) .
Main class:
import java.awt.Color;
import javax.swing.JFrame;
public class Main {
    public static void main(String[] args) {
        MyMap map = new MyMap(); 
        MyCar car = new MyCar();
        Thread x = new Thread(map);
        x.start();
        JFrame f = new JFrame("Broadway Intersection");
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        map.setBackground(Color.white);
        f.add(map);
        f.add(car);
        f.setSize(1366, 738);
        f.setVisible(true); 
    }
}
Map class:
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JPanel;
public class MyMap extends JPanel implements Runnable {
    Color color = Color.RED;
    Color color2 = Color.RED;
    Color color3 = Color.RED;
    Color color4 = Color.RED;
    int[] faza = new int[4];
    int k;
    int faza_curenta = 0;
    public MyMap() {
        faza[0] = 20;
        faza[1] = 20;
        faza[2] = 20;
        faza[3] = 20;
    }
    public void run() {
        color = Color.GREEN;
        while (true) {
            System.out.println("Faza = " + faza_curenta + " k= " + k);
            k++;
            if (k == faza[0]) {
                faza_curenta = 1;
                color = Color.RED;
                color2 = Color.GREEN;
            } else if (k == (faza[0] + faza[1])) {
                faza_curenta = 2;
                color = Color.RED;
                color2 = Color.RED;
                color3 = Color.GREEN;
            } else if (k == (faza[0] + faza[1] + faza[2])) {
                faza_curenta = 3;
                color = Color.RED;
                color3 = Color.RED;
                color4 = Color.GREEN;
            } else if (k == (faza[0] + faza[1] + faza[2] + faza[3])) {
                faza_curenta = 0;
                color = Color.GREEN;
                color4 = Color.RED;
                k = 0;
            }
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
    public void paintComponent(final Graphics g) {
        super.paintComponent(g);
        g.setColor(Color.GREEN);
        g.fillRect(0, 0, 500, 250); // stanga sus
        g.fillRect(900, 0, 500, 250); // dreapta sus
        g.fillRect(0, 500, 500, 250);// stanga jos
        g.fillRect(900, 500, 500, 250); // dreapta jos
        g.setColor(Color.GRAY);
        g.fillRect(500, 0, 400, 900);
        g.fillRect(0, 250, 500, 250);
        g.fillRect(900, 250, 500, 250);
        g.setColor(Color.WHITE);
        g.fillRect(695, 0, 5, 100);// linii verticale
        g.fillRect(695, 150, 5, 100);
        g.fillRect(695, 500, 5, 100);
        g.fillRect(695, 650, 5, 50);
        g.fillRect(0, 370, 50, 5);
        g.fillRect(100, 370, 100, 5); // linii orizontale
        g.fillRect(250, 370, 100, 5);
        g.fillRect(400, 370, 100, 5);
        g.fillRect(900, 370, 100, 5);
        g.fillRect(1050, 370, 100, 5);
        g.fillRect(1200, 370, 100, 5);
        g.setColor(Color.BLACK);
        g.fillRect(470, 220, 30, 30); // semafor Nord
        g.setColor(color);
        g.fillOval(475, 225, 20, 20); // semafor Nord
        g.setColor(Color.BLACK);
        g.fillRect(900, 220, 30, 30); // semafor Est
        g.setColor(color2);
        g.fillOval(905, 225, 20, 20); // semafor Nord
        g.setColor(Color.BLACK);
        g.fillRect(470, 500, 30, 30); // semafor Vest
        g.setColor(color4);
        g.fillOval(475, 505, 20, 20); // semafor Nord
        g.setColor(Color.BLACK);
        g.fillRect(900, 500, 30, 30); // semafor Sud
        g.setColor(color3);
        g.fillOval(905, 505, 20, 20); // semafor Nord
        repaint();
    }
}
And finally MyCar class:
import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JPanel;
public class MyCar extends JPanel  {
    int x; // X position
      int y; // Y position
      int xSpeed; // Speed in the X direction
      int ySpeed; // Speed in the Y direction
    public void paintComponent(final Graphics g) {
        super.paintComponent(g);
        g.setColor(Color.GREEN);
        g.fillRect(420, 200, 30, 30); 
        repaint();
    }   
}