This section illustrates you how to draw grids.
To draw the grids, we have defined rows and columns. The method g.drawLine(0, k * heightOfRow, width, k * heightOfRow) draws the number of rows. The method g.drawLine(k*widthOfRow, 0, k*widthOfRow, height) draws the number of columns.
Now create a canvas and add it to the frame by the following code:
| Grids grid = new Grids(w, h, rows, cols);
Here is the code of DrawGrids.java
Output will be displayed as
If you enjoyed this post then why not add us on Google+? Add us to your Circles
Liked it! Share this Tutorial