import java.awt.*; import java.awt.image.*; public class Graphics4 { static public void main(String[] args) { final int YELLOW = 0xFFFF00; /* ------------------------------------------------ Preparing to draw picture... ------------------------------------------------ */ Canvas pic = new MyCanvas(); // Make a canvas (2 dim array) Frame f = new Frame( "My image" ); // Create a window f.add("Center", pic); // Put the canvas in the window f.setSize(300,300); // Set size of the window f.setVisible(true); // Make window visible /* ------------------------------------------------ Draw a 10x10 box at (100,100) I changed the index to run from 0 to 10 by offsetting the coordinate by 100 --> 100+i will run from 100 to 109 --> 100+j will run from 100 to 109 ------------------------------------------------ */ for (int i = 0; i < 10; i++ ) for (int j = 0; j < 10; j++ ) MyCanvas.Image.setRGB(100+i, 100+j, YELLOW); pic.repaint(); // Repaint the picture } }