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.
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.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); add(grid); |
Here is the code of DrawGrids.java
import java.awt.*;
|
Output will be displayed as
Ads