Ok

A bit further into the book now, and it's shown how to do mouse and keyboard functions. Then cut them down more to using adapters. As its challenge, it says try putting in the keyboard listeners using an adapter.

Ok...

hmm

Code:
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
/*
<applet code="AdapterMnK.class" width=200 height=60>
</applet>
*/

public class AdapterMnK extends Applet {

	public String msg = "";
	public int msgX = 0, msgY = 10;

	public void init() {
		addMouseListener(new MyMouseAdapter(this));
		addMouseMotionListener(new MyMouseMotionAdapter(this));
		addKeyListener(new MyKeyListenerAdapter(this));
	}


	public void paint(Graphics g) {
		g.drawString(msg, msgX, msgY);
	}
}

class MyMouseAdapter extends MouseAdapter {
	AdapterMnK adapterDemo;

	public MyMouseAdapter(AdapterMnK adapterDemo) {
		this.adapterDemo = adapterDemo;
	}
	
	public void mouseClicked(MouseEvent me) {
		adapterDemo.showStatus("Mouse Clicked");
	}
}

class MyMouseMotionAdapter extends MouseMotionAdapter {
	AdapterMnK adapterDemo;

	public MyMouseMotionAdapter(AdapterMnK adapterDemo) {
		this.adapterDemo = adapterDemo;
	}

	public void mouseDragged(MouseEvent me) {
		adapterDemo.showStatus("Mouse dragged");
	}
}

class MyKeyListenerAdapter extends KeyAdapter {
	AdapterMnK adapterDemo;

	public MyKeyListenerAdapter(AdapterMnK adapterdemo) {
		this.adapterDemo = adapterdemo;
	}

	public void KeyTyped(KeyEvent ke) {
		msg += ke.getKeyChar();
		repaint();
	}
}
Now to explain a bit. the book showed the mouse coding (which worked).
I attempted to add the keyboard bit (which doesn't work).

It doesn't like the repaint. So I'm thinking that I've put it in the wrong place and it cannot see the paint/repaint to run it.

I seem to be missing a bit... somewhere