java.awt.event

Back Up Next

 

java.awt.event
The AWT 1.0 Event Model
Event producers and consumers
Events are sorted and dispatched by the programmer
AWT10.java
import java.awt.*;
import java.applet.Applet;

public class AWT10 extends Applet {
	int xval=10, yval=10;

	public boolean mouseDown(Event evt, int x, int y){
		xval = x;
		yval = y;
		repaint();
		return true;
	}

	public void init() { }

	public void start() { } 

	public void paint(Graphics g) {
		g.setColor(Color.black);
		g.drawArc(xval,yval,40,40,0,360);
	}

}
The AWT 1.1 Event Model
Event producers and consumers
Events are sorted and dispatched within the AWT infrastructure
AWT11.java
import java.awt.*;
import java.applet.Applet;
import java.awt.event.MouseEvent;
import java.awt.event.MouseAdapter

public class AWT11 extends Applet{
	int xval=10, yval=10;

	public void init() {
		addMouseListener(new MouseAdapter() {
			public void mousePressed(MouseEvent e) {
				xval = e.getX();
				yval = e.getY();
				repaint;
			}
			});
	}

	public void start() { } 

	public void paint(Graphics g) {
		g.setColor(Color.black);
		g.drawArc(xval,yval,40,40,0,360);
	}

}