1 57 package mime; 58 59 import java.awt.Canvas ; 60 import java.awt.Frame ; 61 import java.awt.Graphics ; 62 import java.awt.Image ; 63 64 public class WSIFFrame extends Frame { 65 private static Frame [] frames = new Frame [2]; 66 private static int frameIndex = 0; 67 private Image im = null; 68 69 public static void display(Image im, String title) throws Exception { 70 Frame f = new WSIFFrame(im,title); 71 frames[frameIndex] = f; 72 frameIndex++; 73 f.add(new WSIFCanvas(im)); 74 f.pack(); 75 f.setLocation(300*frameIndex,200); 76 f.show(); 77 } 78 79 public WSIFFrame(Image im, String title) { 80 super(title); 81 this.im = im; 82 } 83 84 85 public static void close() { 86 for (int i = 0; i < frameIndex; i++) { 87 frames[i].dispose(); 88 frames[i] = null; 89 } 90 frameIndex=0; 91 } 92 93 public void finalize() throws Throwable { 94 for (int i = 0; i < frameIndex; i++) { 95 frames[i].dispose(); 96 frames[i] = null; 97 } 98 frameIndex=0; 99 } 100 101 static class WSIFCanvas extends Canvas { 102 Image im; 103 104 WSIFCanvas(Image im) { 105 super(); 106 this.setSize(200,200); 107 this.im = im; 108 } 109 110 public void paint(Graphics g) { 111 g.drawImage(im, 0, 0, this); 112 } 113 } 114 } 115 116 | Popular Tags |