Hey guys,
I'm drawing a grid using the nested for loop with draw line method.
Any tips on getting this in the center of my screen?
I am currently using the getWidth and getHeight methods of my center panel but it is still drawing in the top left corner.
It's to do with my drawLine method but I can't get it right...
for(int i = 1; i <= x; i++) { // y
for(int e = 1; e <= y; e++) { // x
g.drawLine(i*h, 0,i*h, centerHeight); // y line
g.drawLine(0 ,e*w, centerWidth, e*w); // x line
int X=0;int Y=0;
if (i == 1 & e == 1) {
X = (i*w+i*w) - roverWidth;
Y = ((5-e)*h+(5-e)*h) + roverHeight;
lblRover.setBounds(0,0,X, Y);
}
}