import java.awt.*; import javax.swing.*; /** * A little box with a number inside it, * belongs to a Row */ public class Box { /** Classvar counter for next ID number */ static private int nextID = 1; /** Our own ID number */ private int id; public Box () { // Take next available ID number id = nextID++; } public void draw (Graphics g, Rectangle loc) { Graphics2D g2 = (Graphics2D) g; g2.setColor (Color.BLACK); g2.fill (loc); g2.setColor (Color.WHITE); g2.drawString (String.valueOf (id), loc.x+5, loc.y+15); g2.setColor (Color.BLACK); } }