I would like to code a maze on Java Netbeans. I am trying to display a 2d array as a maze on a canvas but I have no idea where to start. Do I code the maze in a java class then call it from the jframe? I have found this method online but am not sure how to incorporate it to fill a canvas or anything else that can display it:
public void grids(Graphics g)
{
for (int row = 0; row < 20; row++) {
for (int col = 0; col < 20; col++) {
fillColor = Color.BLUE;
g.setColor(fillColor);
g.fillRect(col * 30, row * 30, 30, 30);
g.setColor(Color.BLACK);
g.drawRect(col * 30, row * 30, 30, 30);
}
}
} //End of grids method
I would really appreciate any help. I am new to working with GUIs…
I have tried to instantiate an object of the class and call this method but was not sure what a graphics object was. It did not work.