FileDocCategorySizeDatePackage
Mover3.javaAPI DocExample3729Thu Mar 25 21:30:24 GMT 2004None

Mover3

public class Mover3 extends Mover implements MouseListener
Extend Mover by adding the ability to start and stop the thread just by clocking the mouse.

Fields Summary
protected volatile boolean
threadSuspended
Constructors Summary
Methods Summary
public voidinit()

		System.out.println("Mover3 starting");
		super.init();
		addMouseListener(this);
		System.out.println("Mover3 initted");
	
public voidmouseClicked(java.awt.event.MouseEvent e)

		// nothing 
	
public voidmouseEntered(java.awt.event.MouseEvent $1)

		// nothing
	
public voidmouseExited(java.awt.event.MouseEvent $1)

		// nothing
	
public synchronized voidmousePressed(java.awt.event.MouseEvent e)

		e.consume();

		System.out.println("mousePressed");

		threadSuspended = !threadSuspended;

		if (!threadSuspended)
			notifyAll();
	
public voidmouseReleased(java.awt.event.MouseEvent e)

		// nothing 
	
public voidrun()

		int w = getSize().width;
		while (!done) {
			try {
                Thread.sleep(interval);

                synchronized(this) {
                    while (threadSuspended)
                        wait();
                }

			} catch (InterruptedException canthappen) {
				// Do nothing
			}
			if (offset++ > w)
				offset = 0;
			repaint();
		}