import java.awt.*; import java.net.*; public class Screen extends Panel{ Image offimage; Graphics offgraphics; Dimension offdimension; public void paint(Graphics g) { Dimension d = size(); if ((offgraphics == null) || (offdimension.width != d.width) || (offdimension.height != d.height)) { p("initialized graphics"); setForeground(Color.black); setBackground(Color.black); offimage = createImage(d.width, d.height); offgraphics = offimage.getGraphics(); offdimension = d; } g.drawImage(offimage, 0, 0, this); } public void update(Graphics g){ paint(g); } public void showImage(Image i) { Dimension d = size(); // if ((i.getWidth(this) > d.width) || // (i.getHeight(this) > d.height)) { // if ((i.getWidth(this) - d.width) > // (i.getHeight(this) - d.height)) { //i = i.getScaledInstance(d.width, -1 , i.SCALE_SMOOTH); //} else { //i = i.getScaledInstance(-1, d.height, i.SCALE_SMOOTH); //} //MediaTracker mt = new MediaTracker(this); //mt.addImage(i, 1); //try{ //mt.waitForID(1); //} //catch (Exception e){ //System.out.println(e); //} //} System.out.print(" at "+d.width+"x"+d.height); offgraphics.clearRect(0,0, d.width, d.height); offgraphics.drawImage(i,0,0,this); // offimage = i; repaint(); } private void p(String s) { System.out.println(s); } private void p(Exception e) { System.out.println(e); } }