import java.awt.*; import java.awt.image.*; public class Graphics8 { 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(410,340); // Set size of the window f.setVisible(true); // Make window visible /* ------------------------------------------------ Draw triangle ------------------------------------------------ */ for (int col = 0; col < 400; col++ ) for (int row = 0; row < 300; row++ ) if ( 3*col + 4*row <= 1200 ) MyCanvas.Image.setRGB(col, row, YELLOW); pic.repaint(); // Repaint the picture } }