I am working on an assignment for my java class. The assignment is to draw an image of a car (van in my case) and make it drive across the screen. We are supposed to do this with the help of a timer. I have tried to base my code somewhat on an example given from our textbook. I can't seem to get it to work, I don't have any compiler errors it just simply doesn't work. I'll attach what I have so far. Also thanks for taking the time to look this over.

CarTest.java

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class CarTest
{
//-----------------------------------------------------------------
// Displays the main frame of the program.
//-----------------------------------------------------------------
public static void main (String[] args)
{
JFrame frame = new JFrame ("Car");
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(new CarPanel());
frame.pack();
frame.setVisible(true);
}
}




Car.java

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Car
{
private int CarWidth, CarHeight, WindowWidth, WindowHeight, Tire;

private int CarX, CarY, WindowX, WindowY, FrontTireX, FrontTireY, BackTireX, BackTireY;
private Color color;

public void Car()
{

CarX = 10;
CarY = 30;
CarWidth = 100;
CarHeight = 50;

WindowX = CarX+70;
WindowY = CarY+10;
WindowWidth = 30;
WindowHeight = 20;

FrontTireX = CarX+70;
FrontTireY = CarY+40;
Tire = 20;


BackTireX = CarX+10;
BackTireY = CarY+40;


}


public void SetCarX(int carx)
{
CarX = carx;
}
public void SetCarY(int cary)
{
CarY = cary;
}
public void SetCarWidth(int carwidth)
{
CarWidth = carwidth;
}
public void SetCarHeight(int carheight)
{
CarHeight = carheight;
}
public void SetWindowX(int windowx)
{
WindowX = windowx;
}
public void SetWindowY(int windowy)
{
WindowY = windowy;
}
public void SetWindowWidth(int windowwidth)
{
WindowWidth = windowwidth;
}
public void SetWindowHeight(int windowheight)
{
WindowHeight = windowheight;
}
public void SetFrontTireX(int fronttirex)
{
FrontTireX=fronttirex;
}
public void SetFrontTireY(int fronttirey)
{
FrontTireY = fronttirey;
}
public void SetTire(int tire)
{
Tire = tire;
}
public void SetBackTireX(int backtirex)
{
BackTireX=backtirex;
}
public void SetBackTirey(int backtirey)
{
BackTireY=backtirey;
}


public int GetCarX()
{
return CarX;
}
public int GetCarY()
{
return CarY;
}
public int GetCarWidth()
{
return CarWidth;
}
public int GetCarHeight()
{
return CarHeight;
}
public int GetWindowX()
{
return WindowX;
}
public int GetWindowY()
{
return WindowY;
}
public int GetWindowWidth()
{
return WindowWidth;
}
public int GetWindowHeight()
{
return WindowHeight;
}
public int GetFrontTireX()
{
return FrontTireX;
}
public int GetFrontTireY()
{
return FrontTireY;
}
public int GetTire()
{
return Tire;
}
public int GetBackTireX()
{
return BackTireX;
}
public int GetBackTireY()
{
return BackTireY;
}
}



CarPanel.java

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class CarPanel extends JPanel
{
private final int WIDTH = 600, HEIGHT = 200;
private final int DELAY = 20, IMAGE_SIZE=100;
private Timer timer;
private int moveX;
private Car Car1;
int CarX1, WindowX1, FrontTireX1, BackTireX1;
// Sets up the panel, including the timer
public CarPanel()
{
Car1 = new Car();
timer = new Timer(DELAY, new CarListener());
moveX = 3;

setPreferredSize (new Dimension(WIDTH, HEIGHT));
setBackground(Color.blue);
timer.start();
}


// Draws the image in the current location.

public void paintComponent (Graphics page)
{
page.setColor(Color.GREEN);
page.fillRect(Car1.GetCarX(), Car1.GetCarY(), Car1.GetCarWidth(), Car1.GetCarHeight());

page.setColor(Color.CYAN);
page.fillRect(Car1.GetWindowX(), Car1.GetWindowY(), Car1.GetWindowWidth(), Car1.GetWindowHeight());

page.setColor(Color.BLACK);
page.fillOval(Car1.GetFrontTireX(), Car1.GetFrontTireY(), Car1.GetTire(), Car1.GetTire());
page.fillOval(Car1.GetBackTireX(), Car1.GetBackTireY(), Car1.GetTire(), Car1.GetTire());

}
// Represents the action listener for the timer.
private class CarListener implements ActionListener
{
// Updates the position of the car
public void actionPerformed (ActionEvent event)
{
Car1.SetCarX(Car1.GetCarX()+moveX);
Car1.SetWindowX(Car1.GetWindowX()+moveX);
Car1.SetFrontTireX(Car1.GetFrontTireX()+moveX);
Car1.SetBackTireX(Car1.GetBackTireX()+moveX);

if (Car1.GetCarX() <=0 || Car1.GetCarX() >=WIDTH-IMAGE_SIZE)
{
moveX = moveX * -1;

repaint();
}
}
}
}