FileDocCategorySizeDatePackage
ClickMe.javaAPI DocExample1090Tue Dec 12 18:58:20 GMT 2000None

ClickMe

public class ClickMe extends Applet implements MouseListener

Fields Summary
private Spot
spot
private static final int
RADIUS
Constructors Summary
Methods Summary
public voidinit()


       
	addMouseListener(this);
    
public voidmouseClicked(java.awt.event.MouseEvent event)

public voidmouseEntered(java.awt.event.MouseEvent event)

public voidmouseExited(java.awt.event.MouseEvent event)

public voidmousePressed(java.awt.event.MouseEvent event)

	
        if (spot == null) {
            spot = new Spot(RADIUS);
        }
	spot.x = event.getX();
	spot.y = event.getY();
	repaint();
    
public voidmouseReleased(java.awt.event.MouseEvent event)

public voidpaint(java.awt.Graphics g)

	//draw a black border and a white background
        g.setColor(Color.white);
	g.fillRect(0, 0, getSize().width - 1, getSize().height - 1);
        g.setColor(Color.black);
	g.drawRect(0, 0, getSize().width - 1, getSize().height - 1);

	//draw the spot
        g.setColor(Color.red);
	if (spot != null) {
	    g.fillOval(spot.x - RADIUS, spot.y - RADIUS, RADIUS * 2, RADIUS * 2);
        }