Professional Documents
Culture Documents
In this chapter we will: introduce event driven programming show how a program can respond to mouse events (e.g. clicks and mouse movements) demonstrate how to implement a listener interface show how mouse events can be used to build highly interactive programs
Java Events
Events are occurrences outside of the program to which the program must respond (e.g. user key press) Event managers are methods that first catch the event Listener classes send messages to an event manager requesting to be notified when a particular message occurs Event managers send messages to listeners notifying them when a particular event occurs
Mouse Motion
mouseMoved will be called each time the mouse makes a significantly large movement mouseDragged will be called instead if thre mouse button is pressed and the mouse makes a significantly large movement
You then need to define all seven mouse methods mouseMoved, mouseDragged, mouseClicked, mousePressed, mouseReleased, mouseEntered, mouseExited