Post: Grid [Class] [Java]
03-23-2011, 08:07 PM #1
kiwimoosical
Bounty hunter
(adsbygoogle = window.adsbygoogle || []).push({});
    public class Grid 
{
private int columns;
private int rows;
private int appletWidth;
private int appletHeight;

private Graphics g;

public Grid(Graphics g, int appletWidth, int appletHeight)
{
this.appletWidth = appletWidth;
this.appletHeight = appletHeight;

this.columns = 0;
this.rows = 0;

this.g = g;
}

public void drawColumns()
{
for(int x = 0; x < this.appletWidth; x += 25)
{
g.drawLine(x, 0, x, this.appletHeight);
columns++;
}
}

public void drawRows()
{
for(int y = 0; y < this.appletHeight; y += 25)
{
g.drawLine(0, y, this.appletWidth, y);
rows++;
}
}

public int getColumnCount()
{
return this.columns;
}

public int getRowCount()
{
return this.rows;
}
}


This class is used for drawing grids on an applet, useful when designing because you don't get a designer, so you can use the grid I give you using this class to help get a better jist of where to place things within your applet.
(adsbygoogle = window.adsbygoogle || []).push({});

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo