Event handling is fundamental to Java programming because it is used to create event driven programs eg • Applets • GUI based windows application
The management of events (mouse click pressing a button etc ) is done using the Observer Pattern principle (or listener)
Model used by Java to handle user interaction with GUI components registered listeners (method of event listener is called import java applet *;
Applets Event Handling Java Programming Using a browser: Create a web page named hello html with the following HTML code:
understand how basic events are handled (in applets) ? learn three ways of event event notification using the component's addActionListener method
AWT Event Handling AWT • Abstract Windowing Toolkit package – java awt • Easier to learn than Motif/X and MFC • Not as easy as using graphical GUI
Delagation Model Java awt event description Sources of Events Event To view the applet using the HTML file it can be included in the HTML file with
Event handling is fundamental to Java programming because it is integral to the creation of many kinds of applications including applets and other types of
To handle mouse events you must implement the MouseListener and the MouseMo onListener interfaces • The following applet displays the current coordinates
In the mousePressed() method we can call the repaint() method Output This program involves Frame and event handling mechanism in which Frame creates a window