a1.html
<applet code="zzz" width=350 height=300></applet>
zzz.java programs
The import commands for all the following programs will be
Program 1import java.awt.*; import java.awt.image.*; import java.applet.Applet;
Program 2public class zzz extends Applet { Image c; int a[] = new int[100 * 100]; public void init () { int n = 0; ImageProducer p; for (int i = 0; i < 100 ; i++) for ( int j = 0; j < 100 ; j++) a[n++]=0xffff0000; p = new MemoryImageSource(100,100,a,0,100); c = createImage(p); } public void paint(Graphics g) { g.drawImage(c,0,0,this); } }
Program 3public class zzz extends Applet { Image c; int a[] = new int[10000]; public void init () { int n = 0; ImageProducer p; for (int i = 0; i < 5000 ; i++) a[n++]=0xffff0000; for ( int j = 0; j < 5000 ; j++) a[n++]=0x0000ff00; p = new MemoryImageSource(100,100,a,0,100); c = createImage(p); } public void paint(Graphics g) { g.drawImage(c,0,0,this); } }
Program 4public class zzz extends Applet { Image c; int a[] = new int[10000]; public void init () { int n = 0; ImageProducer p; for (int i = 0; i < 10000 ; i++) a[n++]=0xffff0000; p = new MemoryImageSource(100,100,a,0,100); c = createImage(p); } public void paint(Graphics g) { g.drawImage(c,0,0,this); } public boolean mouseDown(Event e,int x,int y) { int n = 0; ImageProducer q; for (int i = 0; i < 10000 ; i++) a[n++] = 0x0fff0000; q = new MemoryImageSource(100,100,a,0,100); c = createImage(q); repaint(); return true; } }
Program 5public class zzz extends Applet { Image c;int k = 0; int a[] = new int[10000]; public void init () { int n = 0; ImageProducer p; for (int i = 0; i < 10000 ; i++) a[n++]=0x00ff0000; p = new MemoryImageSource(100, 100, a, 0, 100); c = createImage(p); } public void paint(Graphics g) { g.drawImage(c,0,0,this); } public boolean mouseDown(Event e,int x,int y) { k=k+10; int n = 0; ImageProducer q; for (int i = 0; i < 10000 ; i++) a[n++] = 0x00ff0000 | (k<<24); q = new MemoryImageSource(100, 100, a, 0, 100); c = createImage(q); repaint(); showStatus("Value of k " + k); return true; } }
public class zzz extends Applet { Image c;int k = 0; int a[] = new int[10000]; ImageProducer p; public void init () { int n = 0; for (int i = 0; i < 10000 ; i++) a[n++]=0xffff0000; p = new MemoryImageSource(100, 100, a, 0, 100); c = createImage(p); } public void paint(Graphics g) { g.drawImage(c,0,0,this); } public boolean mouseDown(Event e,int x,int y) { k=k+10; int n = 0; ImageProducer q; for (int i = 0; i < 10000 ; i++) a[n++] = 0xff000000 | (k<<16); q = new MemoryImageSource(100, 100, a, 0, 100); c = createImage(q); repaint(); showStatus("Value of k " + k); return true; } }