I’m attempting to build a Traffic Simulator for a school project. I am using circles in placement of the cars, and went off a previous code. The previous code has the circles be blue, but for the project I’d like them to be black.
In my draw method, I have the color of the circle made. I changed the color from blue to black, as shown below, but in the actual simulation nothing has changed, the circles are still blue. Nowhere else in the program it should be setting the color of the circles. Here’s the code I used from a previous project:
@Override
public void draw(Graphics g) {
g.setColor(Color.BLUE); // Change the color to black
int location = SimulationPanel.getInstance().getXInPixelsFromXInMeters(this.getXLocation());
g.fillOval(location - (HEIGHT / 2), (int) y, HEIGHT, HEIGHT);
}
Here’s my updated code:
@Override
public void draw(Graphics g) {
g.setColor(Color.BLACK); // Change the color to black
int location = SimulationPanel.getInstance().getXInPixelsFromXInMeters(this.getXLocation());
g.fillOval(location - (HEIGHT / 2), (int) y, HEIGHT, HEIGHT);
}
chaos – is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.