import java.awt.*; import java.applet.*; // IMPORTANT NOTE: // Must compile with // javac -deprecation A1a.java // to deal with the fact that this is earlier // version Java, able to run in browsers /* By Futrelle for COM1370 6/22/01. Draws a "fat pixel" grid and fills two of the pixels with black. */ public class A1a extends Applet { int size = 24; // of each pixel, in pixel units int dims = 16; // dimension of the square fat pixel array public void init() { setBackground(Color.white); } // The following is called by the system when loaded // into the browser. public void paint(Graphics g) { g.setColor(Color.black); // color for fills drawGrid(g); // draws the entire grid drawFatPixel(g,5,7); // overwrites one fat pixel with black drawFatPixel(g,11,0); // and another // and labels itself g.drawString("R. Futrelle COM1370 Summer 2001 A1 demo A, 6/22/01", 2*size, 17*size); } // paint public void drawGrid(Graphics g) { System.err.println("This should appear in the Java console window."); // sets the instance variables // draws empty outlined squares for(int i=0; i < dims; i++) for(int j=0;j < dims; j++) g.drawRect(i*size, j*size, size, size); } // drawGrid() // fills one "fat pixel" with current color public void drawFatPixel(Graphics g, int x, int y) { g.fillRect(x*size, y*size, size, size); } // drawFatPixel() }