Hey guys, I have this problem where we have to draw a couple tic tac toe boards and the xs and os. Anyways, I'm drawing the borders to the rectangles and I can't seem to figure out how to do it. Obviously, my method doesn't work, but I was wondering if any of you can help. I would appreciate it, thanks. Here is part of my main method and my draw method.
The part that is giving me trouble is the g.drawLine. I'm just not sure what to use for its parameters. For reference, here is what the end result should look like. Another note, we are using a "Drawing Panel" to avoid some of the complexities of the built in java class until we learn more.
Thanks a lot!
Code:
public static void main(String[] args)
{
DrawingPanel panel = new DrawingPanel (400, 325); //Creates graphics panel
Graphics g = panel.getGraphics();
Color ltBlue = new Color (180, 180, 255); //Creates custom color, Light Blue
panel.setBackground(ltBlue); // Sets background color
//Method call drawBoard
drawBoard(g, 60, 3, 10, 10);
drawBoard(g, 24, 5, 50, 200);
drawBoard(g, 48, 4, 200, 75);
}
public static void drawBoard(Graphics g, int sizeBoard, int dimBoard, int x, int y)
{
//Nested loop for drawing each line of boxes
//The first loop controls the amount of lines drawn
for (int drawTimes = 0; drawTimes < dimBoard; drawTimes++)
{
for (int i = 0; i < dimBoard; i++)
{
g.setColor(Color.BLACK);
g.drawLine(x, y, sizeBoard, sizeBoard);
g.drawRect(x, y, sizeBoard, sizeBoard);
g.setColor(Color.YELLOW);
g.fillRect(x, y, sizeBoard, sizeBoard);
x = x + sizeBoard;
}
y = y + sizeBoard;
x = x - (dimBoard * sizeBoard);
}
}
The part that is giving me trouble is the g.drawLine. I'm just not sure what to use for its parameters. For reference, here is what the end result should look like. Another note, we are using a "Drawing Panel" to avoid some of the complexities of the built in java class until we learn more.
Thanks a lot!