//GridSimple.java //one pixel wide gridlines import java.awt.*; import javax.swing.*; public class GridSimple extends JApplet { int widthGap, heightGap; public void init() { String input; input = JOptionPane.showInputDialog( "Enter gap width in pixels"); widthGap = Integer.parseInt( input ); input = JOptionPane.showInputDialog( "Enter gap height in pixels"); heightGap = Integer.parseInt( input ); /* input = JOptionPane.showInputDialog( "Enter width in cells"); widthCells = Integer.parseInt( input ); input = JOptionPane.showInputDialog( "Enter height in cells"); heightCells = Integer.parseInt( input ); */ } public void paint (Graphics g) { int width=getWidth(), height=getHeight(); for (int r=0; r<=height/heightGap; r++) //rows g.drawLine(0,r*(heightGap+1), width,r*(heightGap+1)); for (int c=0; c<=width/widthGap; c++) //columns g.drawLine(c*(widthGap+1),0, c*(widthGap+1),height); } }