My problem is I need to use only one drawLine. I couldn't figure out how am I supposed to make changes at the same time in x and y while not messing with one and another. I can't use a rectangle.
int x = 25;
int y = 25;
for (int i = 0; i <=8; i++) {
g2d.drawLine(x, y, x+160, y);
y+=20;
}
x = 25;
y = 25;
for (int i = 0; i <=8; i++) {
g2d.drawLine(x, y, x, y+160);
x+=20;
}
Holger Sama's Answer (one for):
My Answer (nested for):