public void paint(Graphics2D g) {
g.fillRect(x, 10, WIDTH, HEIGHT);
g.fillRect(x - 51, 10, WIDTH, HEIGHT);
g.fillRect(x - 102, 10, WIDTH, HEIGHT);
g.fillRect(x - 153, 10, WIDTH, HEIGHT);
g.fillRect(x - 204, 10, WIDTH, HEIGHT);
}
i tried:
for (int x = 230; x > 0; x-=51)
{
g.fillRect(x, 10, WIDTH, HEIGHT);
}
But it is not working.
Is there any way to make my code shorter?