/* * EventTest Java Program Using XOR */ import java.applet.*; import java.awt.*; public class EventTest extends Applet { int maxObj = 3; /* max object number */ mPoint object[]; /* objecct array */ int current = -1, hit = -1; int xofs = 0, yofs = 0; public void init() { /* initial object array */ setBackground(Color.black); setForeground(Color.white); object = new mPoint[maxObj]; /* initial a rectangle */ object[0] = new mRectangle(10, 10, 100, 100); object[0].setColor(Color.red); /* initial a circle */ object[1] = new mCircle(200, 10, 100, 100); object[1].setColor(Color.red); /* initial a triangle */ object[2] = new mTriangle(10, 200, 100, 100); object[2].setColor(Color.red); } /* this method will be called to repond a disclosure */ public void paint(Graphics g) { /* we want to redraw the whole client area */ g = getGraphics(); /* fill background */ g.setColor(getBackground()); g.fillRect(1, 1, size().width-2, size().height-2); /* draw boundry */ g.setColor(getForeground()); g.drawRect(0, 0, size().width-1, size().height-1); /* draw objects */ g.setXORMode(Color.black); for (int i=0; i