import java.awt.*; import java.awt.event.*; public class Screen extends Panel{ Image offimage; Graphics offgraphics; Dimension offdimension; Rectangle r = null; public Screen(MouseListener L, MouseMotionListener ML) { addMouseListener(L); addMouseMotionListener(ML); } public void paint(Graphics g) { Dimension d = getSize(); if ((offgraphics == null) || (offdimension.width != d.width) || (offdimension.height != d.height)) { p("initialized graphics"); setForeground(Color.black); setBackground(Color.white); offimage = createImage(d.width, d.height); offgraphics = offimage.getGraphics(); offdimension = d; r = new Rectangle(d); } g.drawImage(offimage, 0, 0, this); // p("repaint"); } public void update(Graphics g){ paint(g); } public void blank() { offgraphics.clearRect(0, 0, r.width, r.height); } public void clearImage(Image i, int x, int y) { int h = i.getHeight(this); int w = i.getWidth(this); offgraphics.clearRect(x, y, x+w, y+h); } public void showImage(Image i, int x, int y) { offgraphics.drawImage(i, x, y, this); } public void drawHoriz(int y) { offgraphics.drawLine(0, y, r.width, y); } private void p(String s) { System.out.println(s); } private void p(Exception e) { System.out.println(e); } }