Shows mouse events ALT= "Applet could not be loaded" Sorry, it is time to upgrade your browser to a Java powered one.


import java.applet.Applet;
import java.awt.*;

public class MouseUpandDown extends Applet {
	private int xUp, yUp;
	private boolean first;
	private Font f;

	public void init()
	{
		first = true;	//disables statements in paint initially
		f = new Font ("TimesRoman", Font.BOLD, 14);
	}

	public void paint (Graphics g)
	{
		if (first == false )
		{
			String s = "MouseUp at ";
			g.setFont (f);
			s += "(" + xUp + ", " + yUp + ")!";
			g.drawString( s, xUp, yUp);
		}
	}

	public boolean mouseDown (Event e, int x, int y)
	{
		showStatus( "mouseDown at (" + x + ", " + y + ")" );
		return true;
	}

	public boolean mouseUp (Event e, int x, int y)
	{
		first = false;
		xUp = x;
		yUp = y;
		repaint ();
		return true;
	}
}